Browse Source

plan cost download

animeic 2 years ago
parent
commit
bee1bf5ff9
6 changed files with 562 additions and 304 deletions
  1. BIN
      boxcost/.~生产成本表.xlsx
  2. 278 0
      boxcost/api/plan-cost-excel.go
  3. 105 0
      boxcost/api/plan.go
  4. 178 303
      boxcost/api/tmp.json
  5. 1 1
      boxcost/db/db.go
  6. BIN
      boxcost/生产成本表.xlsx

BIN
boxcost/.~生产成本表.xlsx


+ 278 - 0
boxcost/api/plan-cost-excel.go

@@ -0,0 +1,278 @@
+package api
+
+import (
+	"box-cost/db/model"
+	"fmt"
+
+	"github.com/xuri/excelize/v2"
+)
+
+// 生产成本表
+type PlanCostExcel struct {
+	Offset int
+
+	Title string //标题
+
+	Excel *excelize.File
+
+	SheetName string
+
+	AlignCenterStyle int
+
+	Content *model.ProductPlan
+}
+
+func (b *PlanCostExcel) drawTitle() error {
+	tileIndex := b.Offset + 1
+	startCell := fmt.Sprintf("A%d", tileIndex)
+	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("O%d", tileIndex))
+	if err != nil {
+		return err
+	}
+
+	style, err := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+		Font:      &excelize.Font{Bold: true, Size: 18}})
+	if err != nil {
+		return err
+	}
+	err = b.Excel.SetCellStyle(b.SheetName, startCell, startCell, style)
+	if err != nil {
+		return err
+	}
+	b.Excel.SetRowHeight(b.SheetName, tileIndex, 23)
+	b.Excel.SetCellValue(b.SheetName, startCell, b.Title)
+	return nil
+}
+
+func (b *PlanCostExcel) drawTableTitle() error {
+	row := b.Offset + 2
+
+	//A采购项目 B规格(克) 尺寸C-D 数量E 单价F-G 交货时间H 备注I
+	// A产品名称
+	var drawCol = func(prefix string, value string) error {
+		left1Cell := fmt.Sprintf("%s%d", prefix, row)
+		left2Cell := fmt.Sprintf("%s%d", prefix, row+1)
+
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
+		if err != nil {
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
+		if err != nil {
+			return err
+		}
+
+		return b.Excel.SetCellValue(b.SheetName, left1Cell, value)
+	}
+	// var drawCol1 = func(prefix string, value1 string, value2 string) error {
+	// 	topCell := fmt.Sprintf("%s%d", prefix, row)
+	// 	bottomCell := fmt.Sprintf("%s%d", prefix, row+1)
+	// 	b.Excel.SetCellStyle(b.SheetName, topCell, topCell, b.AlignCenterStyle)
+	// 	b.Excel.SetCellValue(b.SheetName, topCell, value1)
+	// 	b.Excel.SetCellStyle(b.SheetName, bottomCell, bottomCell, b.AlignCenterStyle)
+	// 	b.Excel.SetCellValue(b.SheetName, bottomCell, value2)
+	// 	return nil
+	// }
+
+	var drawCol2 = func(prefix1 string, prefix2 string, value1 string, value2 string, value3 string) error {
+		left1Cell := fmt.Sprintf("%s%d", prefix1, row)
+		left2Cell := fmt.Sprintf("%s%d", prefix2, row)
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
+		if err != nil {
+			return err
+		}
+		if err != nil {
+			fmt.Println(err)
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left2Cell, b.AlignCenterStyle)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
+
+		val2Cel := fmt.Sprintf("%s%d", prefix1, row+1)
+		b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
+
+		val3Cel := fmt.Sprintf("%s%d", prefix2, row+1)
+		b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
+		return nil
+	}
+	var drawCol3 = func(prefix1 string, prefix2 string, prefix3 string, value1 string, value2 string, value3 string, value4 string) error {
+		left1Cell := fmt.Sprintf("%s%d", prefix1, row)
+		// left2Cell := fmt.Sprintf("%s%d", prefix2, row)
+		left3Cell := fmt.Sprintf("%s%d", prefix3, row)
+		err := b.Excel.MergeCell(b.SheetName, left1Cell, left3Cell)
+		if err != nil {
+			return err
+		}
+		if err != nil {
+			fmt.Println(err)
+			return err
+		}
+		err = b.Excel.SetCellStyle(b.SheetName, left1Cell, left3Cell, b.AlignCenterStyle)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, left1Cell, value1)
+
+		val2Cel := fmt.Sprintf("%s%d", prefix1, row+1)
+		b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val2Cel, value2)
+
+		val3Cel := fmt.Sprintf("%s%d", prefix2, row+1)
+		b.Excel.SetCellStyle(b.SheetName, val3Cel, val3Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val3Cel, value3)
+
+		val4Cel := fmt.Sprintf("%s%d", prefix3, row+1)
+		b.Excel.SetCellStyle(b.SheetName, val4Cel, val4Cel, b.AlignCenterStyle)
+		b.Excel.SetCellValue(b.SheetName, val4Cel, value4)
+		return nil
+	}
+
+	drawCol("A", "产品名称")
+	drawCol("B", "产品配料名称")
+	drawCol2("C", "D", "材料/工序", "材料", "工序")
+	drawCol("E", "供应商名称")
+	drawCol3("F", "G", "H", "规格", "厚度(纸克)", "长", "宽")
+	drawCol("I", "单位")
+	drawCol2("J", "K", "数量", "下单数量", "成品数量")
+	drawCol2("L", "M", "单价(预算)", "单价1", "单价2")
+	drawCol("N", "预算金额")
+	drawCol("O", "汇总金额")
+
+	return nil
+}
+
+func (b *PlanCostExcel) drawTableContent() error {
+	row := b.Offset + 4
+
+	var DrawRow = func(rowIndex int, values ...string) {
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "G", "K", "L", "M", "N", "O"}
+		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)
+		}
+	}
+	comps := b.Content.Pack.Components
+	if len(comps) > 0 {
+		row1 := row
+		for _, comp := range comps {
+			if len(comp.Mats) > 0 {
+				startRow := row
+				for _, mat := range comp.Mats {
+					// 材料
+					supplierName := ""
+					if mat.Supplier.SupplierInfo != nil {
+						supplierName = mat.Supplier.SupplierInfo.Name
+
+					}
+					heigth := fmt.Sprintf("%.2f", mat.MatInfo.Heigth)
+					width := fmt.Sprintf("%.2f", mat.MatInfo.Width)
+					orderCount := fmt.Sprintf("%.2f", mat.Supplier.OrderCount)
+					price := fmt.Sprintf("%.2f", mat.MatInfo.Price)
+					calcName := ""
+					if mat.Supplier.Calc != nil {
+						calcName = mat.Supplier.Calc.Name
+					}
+					orderPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderPrice)
+					orderRealPrice := fmt.Sprintf("%.2f", mat.Supplier.OrderRealPrice)
+					DrawRow(row, b.Content.Name, "", mat.MatInfo.Name, "", supplierName, mat.MatInfo.Norm, heigth, width, mat.MatInfo.Unit, orderCount, "-", calcName, price, orderPrice, orderRealPrice)
+
+					row++
+					if len(mat.Crafts) > 0 {
+						// 工序
+						for _, craft := range mat.Crafts {
+							craftSupplierName := ""
+							if craft.Supplier.SupplierInfo != nil {
+								craftSupplierName = craft.Supplier.SupplierInfo.Name
+
+							}
+							carftOrderCount := fmt.Sprintf("%.2f", craft.Supplier.OrderCount)
+							carftCalcName := ""
+							if craft.Supplier.Calc != nil {
+								carftCalcName = craft.Supplier.Calc.Name
+							}
+							carftPrice := fmt.Sprintf("%.2f", craft.CraftInfo.Price)
+							carftOrderPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderPrice)
+							carftOrderRealPrice := fmt.Sprintf("%.2f", craft.Supplier.OrderRealPrice)
+							DrawRow(row, b.Content.Name, "", "", craft.CraftInfo.Name, craftSupplierName, craft.CraftInfo.Norm, "", "", craft.CraftInfo.Unit, carftOrderCount, "-", carftCalcName, carftPrice, carftOrderPrice, carftOrderRealPrice)
+							row++
+
+						}
+					}
+				}
+				endRow := row - 1
+				startCell := fmt.Sprintf("%s%d", "B", startRow)
+				// left2Cell := fmt.Sprintf("%s%d", prefix2, row)
+				endCell := fmt.Sprintf("%s%d", "B", endRow)
+				b.Excel.MergeCell(b.SheetName, startCell, endCell)
+				err := b.Excel.SetCellStyle(b.SheetName, startCell, endCell, b.AlignCenterStyle)
+				if err != nil {
+					return err
+				}
+				b.Excel.SetCellValue(b.SheetName, startCell, comp.Name)
+
+			}
+		}
+
+		endRow := row - 1
+		startCell := fmt.Sprintf("%s%d", "A", row1)
+		endCell := fmt.Sprintf("%s%d", "A", endRow)
+		b.Excel.MergeCell(b.SheetName, startCell, endCell)
+		err := b.Excel.SetCellStyle(b.SheetName, startCell, endCell, b.AlignCenterStyle)
+		if err != nil {
+			return err
+		}
+		b.Excel.SetCellValue(b.SheetName, startCell, b.Content.Name)
+	}
+
+	return nil
+}
+
+func (b *PlanCostExcel) Draws() {
+	b.drawTitle()
+	b.drawTableTitle()
+	b.drawTableContent()
+}
+
+func NewPlanCostExcel(f *excelize.File) *PlanCostExcel {
+
+	border := []excelize.Border{
+		{Type: "top", Style: 1, Color: "000000"},
+		{Type: "left", Style: 1, Color: "000000"},
+		{Type: "right", Style: 1, Color: "000000"},
+		{Type: "bottom", Style: 1, Color: "000000"},
+	}
+
+	styleLeft, _ := f.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+		Border:    border,
+		Font:      &excelize.Font{Size: 10},
+	})
+
+	b := &PlanCostExcel{
+		Title:            "生产成本表",
+		SheetName:        "Sheet1",
+		Excel:            f,
+		Offset:           0,
+		AlignCenterStyle: styleLeft,
+	}
+
+	f.SetColWidth(b.SheetName, "A", "A", 17)
+	f.SetColWidth(b.SheetName, "B", "B", 13)
+	f.SetColWidth(b.SheetName, "C", "E", 12)
+	f.SetColWidth(b.SheetName, "F", "O", 9.5)
+	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
+	return b
+}

+ 105 - 0
boxcost/api/plan.go

@@ -35,8 +35,113 @@ func ProductPlan(r *GinRouter) {
 	// 下载部件打印单
 	r.GET("/bill/plan/download", DownLoadPlan)
 
+	// 生产成本表
+	r.GET("/plan/cost/download", DownLoadPlanCost)
+
 }
 
+func DownLoadPlanCost(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	_planId := c.Query("id")
+	planId, err := primitive.ObjectIDFromHex(_planId)
+	if err != nil {
+		return nil, errors.New("packId错误")
+	}
+	plan := model.ProductPlan{}
+	found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+		CollectName: repo.CollectionProductPlan,
+		Query:       repo.Map{"_id": planId},
+	}, &plan)
+	if !found || err != nil {
+		return nil, errors.New("数据未找到")
+	}
+
+	f := excelize.NewFile()
+	// Create a new sheet.
+	index := f.NewSheet("Sheet1")
+	f.SetActiveSheet(index)
+	f.SetDefaultFont("宋体")
+	planCostExcel := NewPlanCostExcel(f)
+	planCostExcel.Content = &plan
+	planCostExcel.Title = fmt.Sprintf("生产成本表(%s)", "梦华月色8600盒")
+	// 					//设置对应的数据
+	// produceExcel.Offset = offset
+	planCostExcel.Draws()
+
+	// info := model.Setting{}
+	// repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+	// 	CollectName: "infos",
+	// }, &info)
+
+	// offset := 0
+	// for _, mat := range curComp.Mats {
+	// 	// 采购单
+	// 	_purchaseId := mat.BillId
+	// 	purchaseId, err := primitive.ObjectIDFromHex(_purchaseId)
+	// 	if err == nil {
+	// 		purchase := model.PurchaseBill{}
+	// 		found, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+	// 			CollectName: repo.CollectionBillPurchase,
+	// 			Query:       repo.Map{"_id": purchaseId},
+	// 		}, &purchase)
+	// 		if found {
+	// 			purchaseExcel := NewPurchaseBill(f)
+	// 			purchaseExcel.Content = &purchase
+	// 			purchaseExcel.Title = fmt.Sprintf("%s原材料采购单", info.CompanyName)
+	// 			//设置对应的数据
+	// 			purchaseExcel.Offset = offset
+	// 			purchaseExcel.Draws()
+
+	// 			offset += 15
+	// 		}
+	// 	}
+	// 	if len(mat.Crafts) > 0 {
+	// 		for _, carft := range mat.Crafts {
+	// 			// 加工单
+	// 			_produceId := carft.BillId
+	// 			produceId, err := primitive.ObjectIDFromHex(_produceId)
+	// 			if err == nil {
+	// 				produce := model.ProduceBill{}
+	// 				found, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+	// 					CollectName: repo.CollectionBillProduce,
+	// 					Query:       repo.Map{"_id": produceId},
+	// 				}, &produce)
+	// 				if found {
+	// 					produceExcel := NewProduceBill(f)
+	// 					produceExcel.Content = &produce
+	// 					produceExcel.Title = fmt.Sprintf("%s加工单", info.CompanyName)
+	// 					//设置对应的数据
+	// 					produceExcel.Offset = offset
+	// 					produceExcel.Draws()
+
+	// 					offset += 15
+	// 				}
+
+	// 			}
+	// 		}
+	// 	}
+	// }
+
+	// 另存为
+	// _ = os.MkdirAll("excel", os.ModePerm)
+	// filename1 := time.Now().Format("20060102150405") + ".xlsx"
+	filename1 := "生产成本表.xlsx"
+	err = f.SaveAs(filename1)
+	if err != nil {
+		return nil, err
+	}
+
+	// c.Header("Content-Type", "application/octet-stream")
+	// c.Header("Content-Disposition", "attachment; filename="+"planCost.xlsx")
+	// c.Header("Content-Transfer-Encoding", "binary")
+
+	// err = f.Write(c.Writer)
+	// if err != nil {
+	// 	return nil, err
+	// }
+	return plan, nil
+
+	return nil, nil
+}
 func DownLoadPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	_planId := c.Query("id")
 	compId := c.Query("compId")

+ 178 - 303
boxcost/api/tmp.json

@@ -1,84 +1,88 @@
 {
-  "billStates": {
-    "638ef5310027470dd3a42f5c": "complete",
-    "638ef5340027470dd3a42f5e": "complete",
-    "63a93b7f1e2834349334461c": "created",
-    "63a9447dfad9189c785c7c18": "created",
-    "63a94e049d209b8dfc6c95ee": "created"
-  },
-  "plan": {
-    "_id": "638ef3960027470dd3a42f55",
-    "name": "鲜花饼360g",
+  "errorNo": 200,
+  "result": {
+    "_id": "63904fb753445de55269103b",
+    "name": "测试",
     "pack": {
-      "_id": "638eed77f9039e0980fe5652",
-      "name": "鲜花饼 360g",
-      "thumbnail": "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1670311322997M7wUKS_微信图片_20221206152147.jpg",
+      "_id": "638f108e0027470dd3a42f64",
+      "name": "测试包装",
+      "thumbnail": "",
       "compCounts": 1,
-      "designer": "",
+      "designer": "1232",
       "components": [
         {
-          "id": "638eed77f9039e0980fe5651",
-          "name": "外盒",
-          "thumbnail": "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/png/1670311856420e8wylj_微信图片_20221206153035.png",
+          "id": "638f108e0027470dd3a42f60",
+          "name": "333",
+          "thumbnail": "",
           "count": 1,
           "uv": "",
           "uvSize": "0",
           "mats": [
             {
-              "id": "",
+              "id": "1672128617843638eedb2f9039e0980fe5653",
               "crafts": [
                 {
-                  "id": "",
+                  "id": "16721286489396388430851ba5b3307f8ab600",
                   "size": "0",
-                  "count": 4,
+                  "count": 1,
                   "craftInfo": {
-                    "_id": "635f8bb4971df70343123325",
-                    "name": "4c印刷",
-                    "unit": "版/色",
-                    "price": 0.018,
+                    "_id": "6388430851ba5b3307f8ab60",
+                    "name": "光膜",
+                    "unit": "平方米",
+                    "price": 0.4,
                     "norm": "按文件要求",
                     "remark": "",
-                    "createTime": "2022-10-31T08:47:48.663Z",
-                    "updateTime": "2022-12-01T08:38:57.851Z",
-                    "category": "普通印刷"
+                    "createTime": "2022-12-01T06:00:40.068Z",
+                    "updateTime": "2022-12-01T06:00:40.068Z",
+                    "category": "覆膜"
                   },
                   "supplier": {
-                    "calc": {
-                      "_id": "000000000000000000000000",
-                      "category": "普通印刷",
-                      "name": "普通印刷计价方案1",
-                      "remark": "版费(50)\n起价(普通550,普通+专色800)\n超过10000份减版费",
-                      "param1": "50",
-                      "param2": "550",
-                      "param3": "800",
-                      "param4": "10000",
-                      "param5": "",
-                      "createTime": "0001-01-01T00:00:00Z",
-                      "updateTime": "0001-01-01T00:00:00Z",
-                      "isDefault": null
-                    },
-                    "deliveryTime": "2022-12-09T07:44:51Z",
-                    "orderPrice": 0.072,
-                    "orderCount": 5300,
-                    "orderRealPrice": 581.6,
-                    "supplierInfo": {
-                      "_id": "63846b744d585ba68be6cba1",
-                      "name": "宏川",
-                      "address": "崇州泗潍路333号",
-                      "phone": "13882239198",
-                      "category": "普通印刷",
-                      "createTime": "2022-11-28T08:04:04.791Z",
-                      "updateTime": "2022-12-06T06:55:33.649Z"
-                    }
+                    "calc": null,
+                    "deliveryTime": "2022-12-27T08:11:03Z",
+                    "orderPrice": 0,
+                    "orderCount": 3000,
+                    "orderRealPrice": 0,
+                    "supplierInfo": null
                   },
                   "batchCount": 1,
-                  "batchSizeWidth": 1030,
-                  "batchSizeHeight": 520,
-                  "billId": "638ef5340027470dd3a42f5e",
-                  "remark": "备注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": "1672128855538638eedb2f9039e0980fe5653",
+              "crafts": [
                 {
-                  "id": "",
+                  "id": "167212855882663846db34d585ba68be6cba30",
                   "size": "0",
                   "count": 1,
                   "craftInfo": {
@@ -94,102 +98,51 @@
                   },
                   "supplier": {
                     "calc": null,
-                    "deliveryTime": "2022-12-10T07:44:51Z",
-                    "orderPrice": 0.262,
-                    "orderCount": 5250,
-                    "orderRealPrice": 1375.5,
-                    "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": 1030,
-                  "batchSizeHeight": 520,
-                  "billId": "63a93b7f1e2834349334461c",
-                  "remark": ""
-                },
-                {
-                  "id": "",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638eecaef9039e0980fe564f",
-                    "name": "烫浅金",
-                    "unit": "张",
-                    "price": 0.15,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-12-06T07:18:06.188Z",
-                    "updateTime": "2022-12-06T07:18:06.188Z",
-                    "category": "烫金"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-11T07:44:51Z",
-                    "orderPrice": 0.15,
-                    "orderCount": 5250,
-                    "orderRealPrice": 787.5,
-                    "supplierInfo": {
-                      "_id": "638eecd4f9039e0980fe5650",
-                      "name": "温学刚",
-                      "address": "崇州金鸡路556",
-                      "phone": "13028138020",
-                      "category": "烫金",
-                      "createTime": "2022-12-06T07:18:44.322Z",
-                      "updateTime": "2022-12-06T07:18:44.322Z"
-                    }
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 20,
-                  "batchSizeHeight": 30,
-                  "billId": "63a94e049d209b8dfc6c95ee",
-                  "remark": "备注2"
-                },
-                {
-                  "id": "",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638470a94d585ba68be6cbae",
-                    "name": "模切",
-                    "unit": "张",
-                    "price": 0.04,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-11-28T08:26:17.151Z",
-                    "updateTime": "2022-11-28T08:29:11.086Z",
-                    "category": "模切"
-                  },
-                  "supplier": {
-                    "calc": null,
-                    "deliveryTime": "2022-12-12T07:44:51Z",
-                    "orderPrice": 0.04,
-                    "orderCount": 5200,
-                    "orderRealPrice": 208,
-                    "supplierInfo": {
-                      "_id": "638ee7d9f9039e0980fe564b",
-                      "name": "德顺源",
-                      "address": "崇州市宏业大道北段345号",
-                      "phone": "18180776616",
-                      "category": "模切",
-                      "createTime": "2022-12-06T06:57:29.637Z",
-                      "updateTime": "2022-12-06T06:57:29.637Z"
-                    }
+                    "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": "",
+                  "id": "1672113843354638471684d585ba68be6cbb00",
                   "size": "0",
                   "count": 1,
                   "craftInfo": {
@@ -205,19 +158,11 @@
                   },
                   "supplier": {
                     "calc": null,
-                    "deliveryTime": "2022-12-12T07:44:51Z",
+                    "deliveryTime": "2022-12-27T04:04:10Z",
                     "orderPrice": 0.01,
-                    "orderCount": 5100,
-                    "orderRealPrice": 51,
-                    "supplierInfo": {
-                      "_id": "638ee827f9039e0980fe564d",
-                      "name": "德顺源",
-                      "address": "崇州市宏业大道北段345号",
-                      "phone": "18180776616",
-                      "category": "打包",
-                      "createTime": "2022-12-06T06:58:47.583Z",
-                      "updateTime": "2022-12-06T06:58:47.583Z"
-                    }
+                    "orderCount": 3000,
+                    "orderRealPrice": 30,
+                    "supplierInfo": null
                   },
                   "batchCount": 1,
                   "batchSizeWidth": 0,
@@ -227,176 +172,105 @@
                 }
               ],
               "matInfo": {
-                "_id": "638eedb2f9039e0980fe5653",
-                "name": "太阳白卡",
-                "category": "纸张类",
-                "price": 5400,
-                "unit": "",
-                "norm": "250g",
+                "_id": "63846f924d585ba68be6cba6",
+                "name": "E瓦",
+                "category": "纸",
+                "price": 2,
+                "unit": "平方米",
+                "norm": "130+130",
                 "height": 0,
                 "width": 0,
                 "remark": "",
-                "createTime": "2022-12-06T07:22:26.375Z",
-                "updateTime": "2022-12-06T07:24:48.591Z"
+                "createTime": "2022-11-28T08:21:38.722Z",
+                "updateTime": "2022-11-28T08:30:57.71Z"
               },
               "supplier": {
                 "calc": null,
-                "deliveryTime": "2022-12-08T07:44:51Z",
-                "orderPrice": 0.737,
-                "orderCount": 5400,
-                "orderRealPrice": 3979.8,
+                "deliveryTime": "2022-12-27T04:04:10Z",
+                "orderPrice": 1.28,
+                "orderCount": 3000,
+                "orderRealPrice": 3840,
                 "supplierInfo": {
-                  "_id": "6384668e4d585ba68be6cb9f",
-                  "name": "正大文博",
-                  "address": "四川省成都市温江区分水村清波工业园A3号",
-                  "phone": "13853360367",
-                  "category": "纸张类",
-                  "createTime": "2022-11-28T07:43:10.638Z",
-                  "updateTime": "2022-12-06T07:19:45.089Z"
+                  "_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": 1050,
-              "batchSizeHeight": 520,
-              "billId": "638ef5310027470dd3a42f5c",
+              "batchSizeWidth": 800,
+              "batchSizeHeight": 800,
+              "billId": "63aa8f4d97479fa5562287cd",
               "remark": ""
             }
           ],
           "remark": "",
-          "totalPrice": 6983.4
+          "totalPrice": 3870
         },
         {
-          "id": "1670311794063",
-          "name": "内卡",
-          "thumbnail": "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/png/1670311942234A5P3ic_微信图片_20221206153145.png",
+          "id": "1670397519144",
+          "name": "盒盖",
+          "thumbnail": "",
           "count": 1,
           "uv": "",
-          "uvSize": "0",
+          "uvSize": "200*300",
           "mats": [
             {
-              "id": "",
+              "id": "1670397527450638eedb2f9039e0980fe5653",
               "crafts": [
                 {
-                  "id": "",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638ef06b0027470dd3a42f51",
-                    "name": "单色印刷",
-                    "unit": "套",
-                    "price": 400,
-                    "norm": "按文件要求",
-                    "remark": "",
-                    "createTime": "2022-12-06T07:34:03.326Z",
-                    "updateTime": "2022-12-06T07:34:03.326Z",
-                    "category": "普通印刷"
-                  },
-                  "supplier": {
-                    "calc": {
-                      "_id": "63736d159094a81dd2cc45f2",
-                      "category": "普通印刷",
-                      "name": "普通印刷计价方案1",
-                      "remark": "版费(50)\n起价(普通550,普通+专色800)\n超过10000份减版费",
-                      "param1": "50",
-                      "param2": "550",
-                      "param3": "800",
-                      "param4": "10000",
-                      "param5": "",
-                      "createTime": "0001-01-01T00:00:00Z",
-                      "updateTime": "2022-12-01T05:54:29.052Z",
-                      "isDefault": true
-                    },
-                    "deliveryTime": "2022-12-06T07:44:51Z",
-                    "orderPrice": 0.018,
-                    "orderCount": 10000,
-                    "orderRealPrice": 550,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                },
-                {
-                  "id": "",
-                  "size": "0",
+                  "id": "1670397527450638471684d585ba68be6cbb00",
+                  "size": "100*200",
                   "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-06T07:44:51Z",
-                    "orderPrice": 0,
-                    "orderCount": 10000,
-                    "orderRealPrice": 0,
-                    "supplierInfo": null
-                  },
-                  "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
-                  "billId": "",
-                  "remark": ""
-                },
-                {
-                  "id": "",
-                  "size": "0",
-                  "count": 1,
-                  "craftInfo": {
-                    "_id": "638470a94d585ba68be6cbae",
-                    "name": "模切",
+                    "_id": "638471684d585ba68be6cbb0",
+                    "name": "打包",
                     "unit": "张",
-                    "price": 0.04,
+                    "price": 0.01,
                     "norm": "按文件要求",
                     "remark": "",
-                    "createTime": "2022-11-28T08:26:17.151Z",
-                    "updateTime": "2022-11-28T08:29:11.086Z",
-                    "category": "模切"
+                    "createTime": "2022-11-28T08:29:28.343Z",
+                    "updateTime": "2022-11-28T08:29:28.343Z",
+                    "category": "打包"
                   },
                   "supplier": {
                     "calc": null,
-                    "deliveryTime": "2022-12-06T07:44:51Z",
-                    "orderPrice": 0.04,
-                    "orderCount": 10000,
-                    "orderRealPrice": 400,
+                    "deliveryTime": "2022-12-07T08:32:48Z",
+                    "orderPrice": 0.01,
+                    "orderCount": 3000,
+                    "orderRealPrice": 30,
                     "supplierInfo": null
                   },
                   "batchCount": 1,
-                  "batchSizeWidth": 0,
-                  "batchSizeHeight": 0,
+                  "batchSizeWidth": 100,
+                  "batchSizeHeight": 200,
                   "billId": "",
                   "remark": ""
                 },
                 {
-                  "id": "",
+                  "id": "1670397527450638470d24d585ba68be6cbaf1",
                   "size": "0",
                   "count": 1,
                   "craftInfo": {
-                    "_id": "638471684d585ba68be6cbb0",
-                    "name": "打包",
+                    "_id": "638470d24d585ba68be6cbaf",
+                    "name": "粘盒",
                     "unit": "张",
-                    "price": 0.01,
+                    "price": 0.08,
                     "norm": "按文件要求",
                     "remark": "",
-                    "createTime": "2022-11-28T08:29:28.343Z",
-                    "updateTime": "2022-11-28T08:29:28.343Z",
-                    "category": "打包"
+                    "createTime": "2022-11-28T08:26:58.869Z",
+                    "updateTime": "2022-11-28T08:27:24.914Z",
+                    "category": "粘盒"
                   },
                   "supplier": {
                     "calc": null,
-                    "deliveryTime": "2022-12-06T07:44:51Z",
-                    "orderPrice": 0.01,
-                    "orderCount": 10000,
-                    "orderRealPrice": 100,
+                    "deliveryTime": "2022-12-07T08:32:48Z",
+                    "orderPrice": 0.08,
+                    "orderCount": 3000,
+                    "orderRealPrice": 240,
                     "supplierInfo": null
                   },
                   "batchCount": 1,
@@ -421,10 +295,10 @@
               },
               "supplier": {
                 "calc": null,
-                "deliveryTime": "2022-12-06T07:44:51Z",
-                "orderPrice": 0,
-                "orderCount": 10000,
-                "orderRealPrice": 0,
+                "deliveryTime": "2022-12-07T08:32:48Z",
+                "orderPrice": 0.081,
+                "orderCount": 3000,
+                "orderRealPrice": 243,
                 "supplierInfo": {
                   "_id": "6384668e4d585ba68be6cb9f",
                   "name": "正大文博",
@@ -436,25 +310,26 @@
                 }
               },
               "batchCount": 1,
-              "batchSizeWidth": 0,
-              "batchSizeHeight": 0,
-              "billId": "63a9447dfad9189c785c7c18",
-              "remark": "保质保量"
+              "batchSizeWidth": 200,
+              "batchSizeHeight": 300,
+              "billId": "63915142af181d9ba5d87aaa",
+              "remark": ""
             }
           ],
           "remark": "",
-          "totalPrice": 1050
+          "totalPrice": 513
         }
       ],
-      "createTime": "2022-12-06T07:21:27.169Z",
-      "updateTime": "2022-12-06T07:38:56.936Z"
+      "createTime": "2022-12-06T09:51:10.885Z",
+      "updateTime": "2022-12-27T08:14:19.213Z"
     },
-    "thumbnail": "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1670311322997M7wUKS_微信图片_20221206152147.jpg",
-    "createUser": "1",
-    "total": 10000,
+    "thumbnail": "",
+    "createUser": "31231",
+    "total": 3000,
     "status": "process",
-    "totalPrice": 8033.4,
-    "updateTime": "2022-12-26T07:37:09.145Z",
-    "createTime": "2022-12-06T07:47:34.82Z"
-  }
+    "totalPrice": 4383,
+    "updateTime": "2022-12-27T08:14:26.563Z",
+    "createTime": "2022-12-07T08:32:55.92Z"
+  },
+  "errorDesc": ""
 }

+ 1 - 1
boxcost/db/db.go

@@ -35,7 +35,7 @@ func (db *MongoDB) GetOrCreateDatabase(name string) *mongo.Database {
 }
 
 func NewMongoDB(bus *comm.NatsBus) *MongoDB {
-	inst, err := bus.NewMongoDBFromConfig("box-mongo")
+	inst, err := bus.NewMongoDBFromConfigDev("box-mongo")
 	if err != nil {
 		panic(err)
 	}

BIN
boxcost/生产成本表.xlsx