|
@@ -244,7 +244,6 @@ func DownLoadPlanBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
typeRows := []int{0, 0, 0, 0, 0}
|
|
|
for _, tId := range typeBillIds {
|
|
|
tidArr := strings.Split(tId, "_")
|
|
|
-
|
|
|
var billExcel IExcel
|
|
|
// 采购
|
|
|
billId, _ := primitive.ObjectIDFromHex(tidArr[1])
|
|
@@ -254,32 +253,33 @@ func DownLoadPlanBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
CollectName: repo.CollectionBillPurchase,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &purchase)
|
|
|
- if found {
|
|
|
- sheetName := "采购单"
|
|
|
- index := f.NewSheet(sheetName)
|
|
|
- if flagIndex < 0 {
|
|
|
- flagIndex = index
|
|
|
- }
|
|
|
- // index := f.NewSheet("采购单")
|
|
|
- // f.SetActiveSheet(index)
|
|
|
- billExcel = NewPurchaseBill(f)
|
|
|
- billExcel.SetSheetName(sheetName)
|
|
|
- if purchase.Reviewed == 1 {
|
|
|
- if len(purchase.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
- }
|
|
|
-
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ sheetName := "采购单"
|
|
|
+ index := f.NewSheet(sheetName)
|
|
|
+ if flagIndex < 0 {
|
|
|
+ flagIndex = index
|
|
|
+ }
|
|
|
+ // index := f.NewSheet("采购单")
|
|
|
+ // f.SetActiveSheet(index)
|
|
|
+ billExcel = NewPurchaseBill(f)
|
|
|
+ billExcel.SetSheetName(sheetName)
|
|
|
+ if purchase.Reviewed == 1 {
|
|
|
+ if len(purchase.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
}
|
|
|
- billExcel.SetContent(&purchase)
|
|
|
- billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
|
|
|
|
|
|
}
|
|
|
+ billExcel.SetContent(&purchase)
|
|
|
+ billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
|
|
|
+
|
|
|
billExcel.SetRow(typeRows[0])
|
|
|
billExcel.Draws()
|
|
|
typeRows[0] = billExcel.GetRow() + 5
|
|
@@ -292,36 +292,35 @@ func DownLoadPlanBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
CollectName: repo.CollectionBillProduce,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &produce)
|
|
|
- if found {
|
|
|
- sheetName := "加工单"
|
|
|
-
|
|
|
- if produce.IsPrint {
|
|
|
- sheetName = "加工单-印刷"
|
|
|
- } else if produce.IsLam {
|
|
|
- sheetName = "加工单-覆膜"
|
|
|
- }
|
|
|
- index := f.NewSheet(sheetName)
|
|
|
- if flagIndex < 0 {
|
|
|
- flagIndex = index
|
|
|
- }
|
|
|
- billExcel = NewProduceBill(f)
|
|
|
- billExcel.SetSheetName(sheetName)
|
|
|
- if produce.Reviewed == 1 {
|
|
|
- if len(produce.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
- }
|
|
|
-
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ sheetName := "加工单"
|
|
|
+ if produce.IsPrint {
|
|
|
+ sheetName = "加工单-印刷"
|
|
|
+ } else if produce.IsLam {
|
|
|
+ sheetName = "加工单-覆膜"
|
|
|
+ }
|
|
|
+ index := f.NewSheet(sheetName)
|
|
|
+ if flagIndex < 0 {
|
|
|
+ flagIndex = index
|
|
|
+ }
|
|
|
+ billExcel = NewProduceBill(f)
|
|
|
+ billExcel.SetSheetName(sheetName)
|
|
|
+ if produce.Reviewed == 1 {
|
|
|
+ if len(produce.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
}
|
|
|
- billExcel.SetContent(&produce)
|
|
|
- billExcel.SetTitle(fmt.Sprintf("%s加工单", companyName))
|
|
|
|
|
|
}
|
|
|
+ billExcel.SetContent(&produce)
|
|
|
+ billExcel.SetTitle(fmt.Sprintf("%s加工单", companyName))
|
|
|
|
|
|
if produce.IsPrint {
|
|
|
billExcel.SetRow(typeRows[2])
|
|
@@ -346,37 +345,35 @@ func DownLoadPlanBills(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
CollectName: repo.CollectionBillProduct,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &product)
|
|
|
- if found {
|
|
|
- sheetName := "成品采购单"
|
|
|
- index := f.NewSheet(sheetName)
|
|
|
- if flagIndex < 0 {
|
|
|
- flagIndex = index
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ sheetName := "成品采购单"
|
|
|
+ index := f.NewSheet(sheetName)
|
|
|
+ if flagIndex < 0 {
|
|
|
+ flagIndex = index
|
|
|
+ }
|
|
|
+ billExcel = NewProductBill(f)
|
|
|
+ billExcel.SetSheetName(sheetName)
|
|
|
+ if product.Reviewed == 1 {
|
|
|
+ if len(product.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": product.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
}
|
|
|
- billExcel = NewProductBill(f)
|
|
|
- billExcel.SetSheetName(sheetName)
|
|
|
- if product.Reviewed == 1 {
|
|
|
- if len(product.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": product.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- billExcel.SetContent(&product)
|
|
|
- billExcel.SetTitle(companyName)
|
|
|
|
|
|
}
|
|
|
+ billExcel.SetContent(&product)
|
|
|
+ billExcel.SetTitle(companyName)
|
|
|
+
|
|
|
billExcel.SetRow(typeRows[4])
|
|
|
billExcel.Draws()
|
|
|
typeRows[4] = billExcel.GetRow() + 5
|
|
|
}
|
|
|
- if billExcel == nil {
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
// 设置活跃sheet
|
|
@@ -606,27 +603,28 @@ func DownLoadPlanBillsPdf(c *gin.Context, apictx *ApiSession) (interface{}, erro
|
|
|
CollectName: repo.CollectionBillPurchase,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &purchase)
|
|
|
- if found {
|
|
|
- billExcel = NewPurchaseBill(f)
|
|
|
- if purchase.Reviewed == 1 {
|
|
|
- if len(purchase.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
-
|
|
|
- }
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ billExcel = NewPurchaseBill(f)
|
|
|
+ if purchase.Reviewed == 1 {
|
|
|
+ if len(purchase.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": purchase.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
|
|
|
}
|
|
|
- productName = purchase.ProductName
|
|
|
- supplierName = purchase.Supplier
|
|
|
- serialNumber = purchase.SerialNumber
|
|
|
- billExcel.SetContent(&purchase)
|
|
|
- billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
|
|
|
+
|
|
|
}
|
|
|
+ productName = purchase.ProductName
|
|
|
+ supplierName = purchase.Supplier
|
|
|
+ serialNumber = purchase.SerialNumber
|
|
|
+ billExcel.SetContent(&purchase)
|
|
|
+ billExcel.SetTitle(fmt.Sprintf("%s原材料采购单", companyName))
|
|
|
|
|
|
}
|
|
|
// 工艺
|
|
@@ -636,26 +634,27 @@ func DownLoadPlanBillsPdf(c *gin.Context, apictx *ApiSession) (interface{}, erro
|
|
|
CollectName: repo.CollectionBillProduce,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &produce)
|
|
|
- if found {
|
|
|
- billExcel = NewProduceBill(f)
|
|
|
- if produce.Reviewed == 1 {
|
|
|
- if len(produce.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
- }
|
|
|
-
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ billExcel = NewProduceBill(f)
|
|
|
+ if produce.Reviewed == 1 {
|
|
|
+ if len(produce.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": produce.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
}
|
|
|
- productName = produce.ProductName
|
|
|
- supplierName = produce.Supplier
|
|
|
- serialNumber = produce.SerialNumber
|
|
|
- billExcel.SetContent(&produce)
|
|
|
- billExcel.SetTitle(fmt.Sprintf("%s加工单", companyName))
|
|
|
+
|
|
|
}
|
|
|
+ productName = produce.ProductName
|
|
|
+ supplierName = produce.Supplier
|
|
|
+ serialNumber = produce.SerialNumber
|
|
|
+ billExcel.SetContent(&produce)
|
|
|
+ billExcel.SetTitle(fmt.Sprintf("%s加工单", companyName))
|
|
|
|
|
|
}
|
|
|
// 成品采购
|
|
@@ -665,29 +664,27 @@ func DownLoadPlanBillsPdf(c *gin.Context, apictx *ApiSession) (interface{}, erro
|
|
|
CollectName: repo.CollectionBillProduct,
|
|
|
Query: repo.Map{"_id": billId},
|
|
|
}, &product)
|
|
|
- if found {
|
|
|
- billExcel = NewProductBill(f)
|
|
|
- if product.Reviewed == 1 {
|
|
|
- if len(product.SignUsers) > 0 {
|
|
|
- signs := []*model.Signature{}
|
|
|
- repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionSignature,
|
|
|
- Query: repo.Map{"_id": bson.M{"$in": product.SignUsers}},
|
|
|
- Sort: bson.M{"sort": 1},
|
|
|
- }, &signs)
|
|
|
- billExcel.SetSignatures(signs)
|
|
|
- }
|
|
|
-
|
|
|
+ if !found {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ billExcel = NewProductBill(f)
|
|
|
+ if product.Reviewed == 1 {
|
|
|
+ if len(product.SignUsers) > 0 {
|
|
|
+ signs := []*model.Signature{}
|
|
|
+ repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ CollectName: repo.CollectionSignature,
|
|
|
+ Query: repo.Map{"_id": bson.M{"$in": product.SignUsers}},
|
|
|
+ Sort: bson.M{"sort": 1},
|
|
|
+ }, &signs)
|
|
|
+ billExcel.SetSignatures(signs)
|
|
|
}
|
|
|
- productName = product.ProductName
|
|
|
- supplierName = product.Supplier
|
|
|
- serialNumber = product.SerialNumber
|
|
|
- billExcel.SetContent(&product)
|
|
|
- billExcel.SetTitle(companyName)
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
- if billExcel == nil {
|
|
|
- continue
|
|
|
+ productName = product.ProductName
|
|
|
+ supplierName = product.Supplier
|
|
|
+ serialNumber = product.SerialNumber
|
|
|
+ billExcel.SetContent(&product)
|
|
|
+ billExcel.SetTitle(companyName)
|
|
|
}
|
|
|
billExcel.SetIsPdf("true")
|
|
|
billExcel.Draws()
|