From 260b3fbc34b4e9ae2ee53e4a7917abb72ef848a7 Mon Sep 17 00:00:00 2001
From: dsmzx <dsmzx@123.com>
Date: 星期二, 02 七月 2024 15:44:15 +0800
Subject: [PATCH] 出库/入库打印 修改bug

---
 controllers/operation.go |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/controllers/operation.go b/controllers/operation.go
index d948560..4828007 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -100,6 +100,10 @@
 	params.Status = constvar.OperationStatus_Ready
 	//params.Number = strconv.FormatInt(time.Now().Unix(), 10)
 
+	for _, detail := range params.Details {
+		detail.BaseOperationType = params.BaseOperationType
+	}
+
 	var numberNum int64
 	if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil {
 		util.ResponseFormat(c, code.RequestParamError, err.Error())
@@ -781,15 +785,15 @@
 				return
 			}
 
-			if warehouse.FileTemplateCategoryIn == constvar.FileTemplateCategory_JialianInput1 {
-				fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryIn, operation)
+			if warehouse.FileTemplateCategoryIn == constvar.FileWarehouseCategory_JialianInput2 {
+				fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryIn, operation)
 				if err != nil {
 					util.ResponseFormat(c, code.RequestParamError, err.Error())
 					return
 				}
 
-			} else if warehouse.FileTemplateCategoryIn == constvar.FileWarehouseCategory_JialianInput2 {
-				fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryIn, operation)
+			} else if warehouse.FileTemplateCategoryIn == constvar.FileTemplateCategory_JialianInput1 {
+				fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryIn, operation)
 				if err != nil {
 					util.ResponseFormat(c, code.RequestParamError, err.Error())
 					return
@@ -821,15 +825,15 @@
 				return
 			}
 
-			if warehouse.FileTemplateCategoryOut == constvar.FileTemplateCategory_JialianOutput1 {
-				fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryOut, operation)
+			if warehouse.FileTemplateCategoryOut == constvar.FileWarehouseCategory_JialianOutput2 {
+				fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryOut, operation)
 				if err != nil {
 					util.ResponseFormat(c, code.RequestParamError, err.Error())
 					return
 				}
 
-			} else if warehouse.FileTemplateCategoryOut == constvar.FileWarehouseCategory_JialianOutput2 {
-				fileUrl, err = JialianOperation1(warehouse.FileTemplateCategoryOut, operation)
+			} else if warehouse.FileTemplateCategoryOut == constvar.FileTemplateCategory_JialianOutput1 {
+				fileUrl, err = JialianOperation2(warehouse.FileTemplateCategoryOut, operation)
 				if err != nil {
 					util.ResponseFormat(c, code.RequestParamError, err.Error())
 					return
@@ -997,9 +1001,8 @@
 	}
 
 	fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes())
-	ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644)
 	if err != nil {
-		//ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644)
+		ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644)
 		logx.Errorf("file upload err: %v", err)
 		return "", err
 	}
@@ -1117,8 +1120,8 @@
 	}
 
 	fileUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_File), uuid.NewV4().String()+".xlsx", buf.Bytes())
-	ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644)
 	if err != nil {
+		ioutil.WriteFile("E:\\"+uuid.NewV4().String()+".xlsx", buf.Bytes(), 0644)
 		logx.Errorf("file upload err: %v", err)
 		return "", err
 	}
@@ -1201,7 +1204,6 @@
 		logx.Errorf("file upload err: %v", err)
 		return "", err
 	}
-
 	return fileUrl, nil
 }
 

--
Gitblit v1.8.0