Browse Source

优化pdf

zoie 1 year ago
parent
commit
67ac45618b
5 changed files with 4 additions and 649 deletions
  1. 1 137
      controllers/sales.go
  2. 0 504
      controllers/stock_template.go
  3. 0 3
      go.mod
  4. 1 3
      go.sum
  5. 2 2
      services/stock_template.go

+ 1 - 137
controllers/sales.go

@@ -8,7 +8,6 @@ import (
 	"Medical_ERP/services"
 	"Medical_ERP/utils"
 	"fmt"
-	"github.com/jung-kurt/gofpdf"
 	"github.com/signintech/gopdf"
 	"github.com/xuri/excelize/v2"
 	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/beegouser"
@@ -441,141 +440,6 @@ func (c SalesController) SalesStockOutExcel(reqData dto.SalesStockOutExcelReq) {
 	// 返回生成的 Excel 文件
 	c.Ctx.Output.Download("ofile/" + filename)
 }
-func (c SalesController) SalesStockOutPdf1(reqData dto.SalesStockOutExcelReq) {
-	s := services.Sales{}
-	deptId := beegouser.GetDeptId(c.Ctx)
-	list, err := s.SalesStockOutExcel(&reqData, deptId)
-	if err != nil {
-		c.Error(500, err, err.Error())
-		return
-	}
-	cols := []float64{22, 12, 22, 18, 20, 20, 20, 10, 10, 18, 18}
-
-	header := []string{"品种", "剂型", "规格", "生产企业", "批号", "失效日期", "批准文号", "数量", "单位", "销售单价", "销售金额"}
-	rows := [][]string{}
-	money := 0.0
-	for _, row := range list {
-		temp := []string{}
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldProductName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldDosageFormName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldSpecName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldEnterpriseName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldBatchNumber]))
-		temp = append(temp, fmt.Sprintf("%s", utils.ToDate(row[models.FieldExpiryDate])))
-		if row[models.FieldApprovalNumber] == nil {
-			temp = append(temp, "")
-		} else {
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldApprovalNumber]))
-		}
-		temp = append(temp, fmt.Sprintf("%d", utils.ToInt(row["quantity"])))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldUnitName]))
-		temp = append(temp, fmt.Sprintf("%.2f", utils.ToFloat64(row["sales_unit_price"])))
-		temp = append(temp, fmt.Sprintf("%.2f", utils.ToFloat64(row["sales_money"])))
-		rows = append(rows, temp)
-		money += utils.ToFloat64(row["sales_money"])
-	}
-	rows = append(rows, []string{"", "", "", "", "", "", "", "", "", "", ""})
-
-	pdf := gofpdf.New("P", "mm", "A4", "")
-
-	pdf.AddPage()
-	pdf.AddUTF8Font("simsun", "", "static/fonts/MiSans-Medium.ttf")
-	pdf.SetFont("simsun", "", 20)
-	pdf.SetMargins(10, 10, 10)
-	pdf.SetAutoPageBreak(false, 0)
-	pagew, pageh := pdf.GetPageSize()
-	_, _, _, mbottom := pdf.GetMargins()
-	titleStr := fmt.Sprintf("%s二类出库单", beegouser.GetDeptName(c.Ctx))
-
-	titleWd := pdf.GetStringWidth(titleStr)
-	titleX := (pagew - titleWd) / 2
-	pdf.Text(titleX, 20, titleStr)
-
-	titleX = pagew / 4
-	y := 30.0
-	curx, _ := pdf.GetXY()
-
-	pdf.SetFont("simsun", "", 8)
-	pdf.Text(curx, y, fmt.Sprintf("购货单位:%s", reqData.ReceivingUnit))
-	pdf.Text(titleX+10, y, fmt.Sprintf("下单日期:%s", reqData.Date))
-	//pdf.Text(titleX*2+20, y, fmt.Sprintf("编号:"))
-	//pdf.Text(titleX*3, y, "第1联,共3联(第1联,库房处留存)")
-
-	curx, y = pdf.GetXY()
-	pdf.SetXY(curx, 32)
-	h := 10.0
-	pdf.SetFont("simsun", "", 10)
-	for i := 0; i < len(header); i++ {
-		pdf.CellFormat(cols[i], h, header[i], "1", 0, "CM", false, 0, "")
-	}
-	pdf.Ln(-1)
-	pdf.SetFont("simsun", "", 9)
-	marginCell := 4. // margin of top/bottom of cell
-
-	for _, row := range rows {
-		curx, y = pdf.GetXY()
-		x := curx
-
-		height := 0.
-		_, lineHt := pdf.GetFontSize()
-
-		for i, txt := range row {
-			lines := pdf.SplitLines([]byte(txt), cols[i])
-			h = float64(len(lines))*lineHt + marginCell*float64(len(lines))
-			if h > height {
-				height = h
-			}
-		}
-		// add a new page if the height of the row doesn't fit on the page
-		if pdf.GetY()+height > pageh-mbottom {
-			pdf.AddPage()
-			y = pdf.GetY()
-		}
-		for i, txt := range row {
-			width := cols[i]
-			pdf.Rect(x, y, width, height, "")
-
-			pdf.MultiCell(width, lineHt+marginCell, txt, "", "C", false)
-			x += width
-			pdf.SetXY(x, y)
-		}
-		pdf.SetXY(curx, y+height)
-	}
-
-	curx, y = pdf.GetXY()
-	h = 10.0
-	width := cols[0] + cols[1] + cols[2] + cols[3]
-	pdf.CellFormat(width, h, fmt.Sprintf("整单合计金额(小写):¥%.2f元", money), "1", 0, "CM", false, 0, "")
-	width = cols[4] + cols[5] + cols[6] + cols[7] + cols[8] + cols[9] + cols[10]
-	pdf.CellFormat(width, h, fmt.Sprintf("整单合计金额(大写):%s", utils.AmountConvert(money, true)), "1", 0, "CM", false, 0, "")
-	pdf.SetXY(curx, y+10)
-
-	curx, y = pdf.GetXY()
-	y += 4
-	pdf.Text(curx, y, fmt.Sprintf("开票日期:%s", time.Now().Format("2006年01月02日")))
-	width = cols[0] + cols[1] + cols[2]
-	curx += width
-	pdf.Text(curx, y, fmt.Sprintf("开票员:%s", reqData.Drawer))
-	width = cols[3] + cols[4]
-	curx += width
-	pdf.Text(curx, y, fmt.Sprintf("发货人:%s       财务:%s", reqData.Consigner, reqData.Finance))
-	width = cols[5] + cols[6] + cols[7] + cols[8]
-	curx += width
-	pdf.Text(curx, y, fmt.Sprintf("收货人:%s", reqData.Consignee))
-
-	filename := "二类出库单" + time.Now().Format("20060102150405") + ".pdf"
-	// 保存文件
-	if err = pdf.OutputFileAndClose("ofile/" + filename); err != nil {
-		fmt.Println(err)
-	}
-	defer func() {
-		os.Remove("ofile/" + filename)
-	}()
-
-	// 返回生成的 Excel 文件
-	c.Ctx.Output.Download("ofile/" + filename)
-
-}
 func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 	s := services.Sales{}
 	deptId := beegouser.GetDeptId(c.Ctx)
@@ -642,7 +506,7 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 	y += 10
 	pdf.SetXY(curx, y)
 	for i := 0; i < len(header); i++ {
-		utils.RectFillColor(pdf, header[i], 11, x, y, cols[i], h, 0, 0, 0, gopdf.Center, gopdf.Middle)
+		utils.RectFillColorMultiCell(pdf, header[i], 11, x, y, cols[i], h, 0, 0, 0, gopdf.Center, gopdf.Middle)
 		x += cols[i]
 	}
 

+ 0 - 504
controllers/stock_template.go

@@ -15,7 +15,6 @@ import (
 	"fmt"
 	"github.com/boombuler/barcode"
 	"github.com/boombuler/barcode/code128"
-	"github.com/jung-kurt/gofpdf"
 	"github.com/ser163/png2j"
 	"github.com/signintech/gopdf"
 	"github.com/xuri/excelize/v2"
@@ -547,232 +546,6 @@ func (c StockTemplateController) StockTemplateInventoryExcel(reqData dto.StockTe
 	// 返回生成的 Excel 文件
 	c.Ctx.Output.Download("ofile/" + filename)
 }
-func (c StockTemplateController) StockTemplateInventoryPdf1(reqData dto.StockTemplateInventoryExcelReq) {
-	s := services.StockTemplate{}
-	deptId := beegouser.GetDeptId(c.Ctx)
-	models.InitBasicData(deptId)
-	medicineInfo, err := s.GetMedicineInfo(deptId, map[string]interface{}{
-		"product_id":    reqData.ProductID,
-		"enterprise_id": reqData.EnterpriseID,
-		"spec_id":       reqData.SpecId,
-		"batch_number":  reqData.BatchNumber,
-	})
-	if err != nil {
-		c.Error(global.BadRequest, err, "药品信息不存在")
-		return
-	}
-	var productName, specName, unitName, dosageFormName string
-
-	if id, ok := medicineInfo[models.FieldProductID]; ok {
-		productName = models.Read_Product_Get(utils.ToInt(id))
-	}
-	if id, ok := medicineInfo[models.FieldSpecID]; ok {
-		specName = models.Read_Spec_Get(utils.ToInt(id))
-	}
-	if id, ok := medicineInfo[models.FieldUnitID]; ok {
-		unitName = models.Read_Unit_Get(utils.ToInt(id))
-	}
-	if id, ok := medicineInfo[models.FieldDosageFormID]; ok {
-		dosageFormName = models.Read_DosageForm_Get(utils.ToInt(id))
-	}
-
-	list, err := s.StockTemplateInventoryExcel(&reqData, deptId)
-	if err != nil {
-		c.Error(500, err, err.Error())
-		return
-	}
-	cols := []float64{20, 24, 20, 18, 20, 12, 22, 20, 12, 22, 20, 12, 22, 20, 15}
-
-	rows := [][]string{}
-	for _, row := range list {
-		temp := []string{}
-		temp = append(temp, fmt.Sprintf("%v", row["date"]))
-
-		if utils.ToInt(row["stock_in_id"]) > 0 {
-			temp = append(temp, fmt.Sprintf("%s", row["forwarding_unit"]))
-		} else if utils.ToInt(row["stock_out_id"]) > 0 {
-			temp = append(temp, fmt.Sprintf("%s", row["receiving_unit"]))
-		}
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldEnterpriseName]))
-		if row[models.FieldApprovalNumber] == nil {
-			temp = append(temp, "")
-		} else {
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldApprovalNumber]))
-		}
-		if row[models.FieldQualificationNumber] == nil {
-			temp = append(temp, "")
-		} else {
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldQualificationNumber]))
-		}
-
-		if utils.ToInt(row["stock_in_id"]) > 0 {
-			temp = append(temp, fmt.Sprintf("%d", row["total_in"]))
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldBatchNumber]))
-			temp = append(temp, fmt.Sprintf("%s", utils.ToDate(row[models.FieldExpiryDate])))
-		} else {
-			temp = append(temp, "")
-			temp = append(temp, "")
-			temp = append(temp, "")
-		}
-
-		if utils.ToInt(row["stock_out_id"]) > 0 {
-			temp = append(temp, fmt.Sprintf("%d", row["total_out"]))
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldBatchNumber]))
-			temp = append(temp, fmt.Sprintf("%s", utils.ToDate(row[models.FieldExpiryDate])))
-		} else {
-			temp = append(temp, "")
-			temp = append(temp, "")
-			temp = append(temp, "")
-		}
-
-		temp = append(temp, fmt.Sprintf("%d", row["balance"]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldBatchNumber]))
-		temp = append(temp, fmt.Sprintf("%s", utils.ToDate(row[models.FieldExpiryDate])))
-		temp = append(temp, fmt.Sprintf("%s", row["operator"]))
-		rows = append(rows, temp)
-
-	}
-
-	pdf := gofpdf.New("L", "mm", "A4", "")
-
-	pdf.AddPage()
-	pdf.AddUTF8Font("simsun", "", "static/fonts/MiSans-Medium.ttf")
-	pdf.SetFont("simsun", "", 20)
-	pdf.SetMargins(10, 10, 10)
-	pdf.SetAutoPageBreak(false, 0)
-	pagew, pageh := pdf.GetPageSize()
-	_, _, _, mbottom := pdf.GetMargins()
-	titleStr := "收发登记表"
-
-	titleWd := pdf.GetStringWidth(titleStr)
-	titleX := (pagew - titleWd) / 2
-	pdf.Text(titleX, 20, titleStr)
-
-	titleX = pagew / 3 * 2
-	pdf.SetFont("simsun", "", 10)
-	pdf.Text(titleX, 25, fmt.Sprintf("制品名称:%s 编号", productName))
-	pdf.Text(titleX, 30, fmt.Sprintf("剂型:%s 规格:%s 单位:%s", dosageFormName, specName, unitName))
-
-	h := 16.0
-	curx, y := pdf.GetXY()
-	pdf.SetXY(curx, 35)
-	pdf.CellFormat(cols[0], h, "日期", "1", 0, "CM", false, 0, "")
-	pdf.CellFormat(cols[1], h, "购货/发货单位", "1", 0, "CM", false, 0, "")
-	pdf.CellFormat(cols[2], h, "生产企业", "1", 0, "CM", false, 0, "")
-	pdf.CellFormat(cols[3], h, "批准文号", "1", 0, "CM", false, 0, "")
-	curx, y = pdf.GetXY()
-	width := cols[4]
-	pdf.MultiCell(width, h/2, "批签发合格\n证编号", "1", "CM", false)
-
-	// ------收入
-	curx += width
-	pdf.SetXY(curx, y)
-	width = cols[5] + cols[6] + cols[7]
-	pdf.CellFormat(width, h/2, "收入", "1", 0, "CM", false, 0, "")
-
-	width = cols[5]
-	pdf.SetXY(curx, y+h/2)
-	pdf.CellFormat(width, h/2, "数量", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[6]
-	pdf.CellFormat(width, h/2, "批号", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[7]
-	pdf.CellFormat(width, h/2, "失效日期", "1", 0, "CM", false, 0, "")
-
-	// ------支出
-	curx += width
-	pdf.SetXY(curx, y)
-	width = cols[8] + cols[9] + cols[10]
-	pdf.CellFormat(width, h/2, "支出", "1", 0, "CM", false, 0, "")
-
-	width = cols[8]
-	pdf.SetXY(curx, y+h/2)
-	pdf.CellFormat(width, h/2, "数量", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[9]
-	pdf.CellFormat(width, h/2, "批号", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[10]
-	pdf.CellFormat(width, h/2, "失效日期", "1", 0, "CM", false, 0, "")
-
-	// ------结余
-	curx += width
-	pdf.SetXY(curx, y)
-	width = cols[11] + cols[12] + cols[13]
-	pdf.CellFormat(width, h/2, "结余", "1", 0, "CM", false, 0, "")
-
-	width = cols[11]
-	pdf.SetXY(curx, y+h/2)
-	pdf.CellFormat(width, h/2, "数量", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[12]
-	pdf.CellFormat(width, h/2, "批号", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	pdf.SetXY(curx, y+h/2)
-	width = cols[13]
-	pdf.CellFormat(width, h/2, "失效日期", "1", 0, "CM", false, 0, "")
-
-	curx += width
-	width = cols[14]
-	pdf.SetXY(curx, y)
-	pdf.MultiCell(width, h/2, "经办人\n签字", "1", "CM", false)
-
-	pdf.SetFont("simsun", "", 9)
-	marginCell := 4. // margin of top/bottom of cell
-
-	for _, row := range rows {
-		curx, y = pdf.GetXY()
-		x := curx
-
-		height := 0.
-		_, lineHt := pdf.GetFontSize()
-
-		for i, txt := range row {
-			lines := pdf.SplitLines([]byte(txt), cols[i])
-			h := float64(len(lines))*lineHt + marginCell*float64(len(lines))
-			if h > height {
-				height = h
-			}
-		}
-		// add a new page if the height of the row doesn't fit on the page
-		if pdf.GetY()+height > pageh-mbottom {
-			pdf.AddPage()
-			y = pdf.GetY()
-		}
-		for i, txt := range row {
-			width = cols[i]
-			pdf.Rect(x, y, width, height, "")
-			pdf.MultiCell(width, lineHt+marginCell, txt, "", "CM", false)
-			x += width
-			pdf.SetXY(x, y)
-		}
-		pdf.SetXY(curx, y+height)
-	}
-
-	filename := "收发登记表" + time.Now().Format("20060102150405") + ".pdf"
-	// 保存文件
-	if err := pdf.OutputFileAndClose("ofile/" + filename); err != nil {
-		fmt.Println(err)
-	}
-	defer func() {
-		os.Remove("ofile/" + filename)
-	}()
-
-	// 返回生成的 Excel 文件
-	c.Ctx.Output.Download("ofile/" + filename)
-}
 func (c StockTemplateController) StockTemplateInventoryPdf(reqData dto.StockTemplateInventoryExcelReq) {
 	s := services.StockTemplate{}
 	deptId := beegouser.GetDeptId(c.Ctx)
@@ -1914,283 +1687,6 @@ func (c StockTemplateController) TransportRecordWord(reqData models.TransportRec
 	c.Ctx.Output.Download("ofile/" + filename)
 }
 
-func (c StockTemplateController) TransportRecordPdf1(reqData models.TransportRecord) {
-	s := services.StockTemplate{}
-	deptId := beegouser.GetDeptId(c.Ctx)
-
-	list, err := s.StockTemplateTransportRecordWord(&reqData, deptId)
-	if err != nil {
-		c.Error(500, err, err.Error())
-		return
-	}
-
-	cols := []float64{30, 22, 22, 27, 31, 22, 21, 11, 11}
-
-	header := []string{"品种", "生产企业", "批准文号", "批签发合格编号", "规格(剂/支或粒)", "批号", "失效日期", "数量", "单位"}
-	rows := [][]string{}
-	for _, row := range list {
-		temp := []string{}
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldProductName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldEnterpriseName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldApprovalNumber]))
-		if row[models.FieldQualificationNumber] == nil {
-			temp = append(temp, "")
-		} else {
-			temp = append(temp, fmt.Sprintf("%s", row[models.FieldQualificationNumber]))
-		}
-
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldSpecName]))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldBatchNumber]))
-		temp = append(temp, fmt.Sprintf("%s", utils.ToDate(row[models.FieldExpiryDate])))
-		temp = append(temp, fmt.Sprintf("%d", utils.ToInt(row["quantity"])))
-		temp = append(temp, fmt.Sprintf("%s", row[models.FieldUnitName]))
-		rows = append(rows, temp)
-	}
-	if len(list) < 11 {
-		for i := 0; i < 11-len(list); i++ {
-			rows = append(rows, []string{"", "", "", "", "", "", "", "", ""})
-		}
-	}
-
-	pdf := gofpdf.New("P", "mm", "A4", "")
-
-	pdf.AddPage()
-	pdf.AddUTF8Font("simsun", "", "static/fonts/MiSans-Medium.ttf")
-	pdf.SetFont("simsun", "", 22)
-	pdf.SetMargins(2, 5, 5)
-	pdf.SetAutoPageBreak(true, 0)
-	pagew, pageh := pdf.GetPageSize()
-	_, _, _, mbottom := pdf.GetMargins()
-
-	titleStr := "表3-4 运输记录表"
-	titleWd := pdf.GetStringWidth(titleStr)
-	titleX := (pagew - titleWd) / 2
-	pdf.Text(titleX, 15, titleStr)
-
-	pdf.SetFont("simsun", "", 16)
-	titleStr = "(各级通用)"
-	titleWd = pdf.GetStringWidth(titleStr)
-	titleX = (pagew - titleWd) / 2
-	pdf.Text(titleX, 25, titleStr)
-
-	pdf.SetFont("simsun", "", 10)
-	curx, y := pdf.GetXY()
-	y = 25
-	y += 8
-	pdf.Text(curx, y, "运输工具: □冷藏车  □运输车  □普通车辆  □无  □其他")
-	y += 8
-	pdf.Text(curx, y, "冷藏工具: □冷藏车  □车载冷藏箱  □冷藏箱或冷藏包  □其他")
-	y += 8
-	pdf.Text(curx, y, "配送方式: □本级配送(车牌号:_______) □下级自运(车牌号:_______)")
-
-	y += 10
-	pdf.Text(curx, y, "运输情况:")
-	y += 3
-	pdf.SetXY(curx, y)
-	h := 10.0
-	for i := 0; i < len(header); i++ {
-		pdf.CellFormat(cols[i], h, header[i], "1", 0, "CM", false, 0, "")
-	}
-	pdf.Ln(-1)
-	pdf.SetFont("simsun", "", 9)
-	marginCell := 4. // margin of top/bottom of cell
-	y = pdf.GetY()
-	pdf.SetXY(curx, y)
-	//for _, row := range rows {
-	//	curx, y = pdf.GetXY()
-	//	if y > pageh-mbottom-marginCell {
-	//		pdf.AddPage()
-	//		y = pdf.GetY()
-	//	}
-	//	x := curx
-	//
-	//	height := 0.
-	//	_, lineHt := pdf.GetFontSize()
-	//
-	//	for i, txt := range row {
-	//		lines := pdf.SplitLines([]byte(txt), cols[i])
-	//		h = float64(len(lines))*lineHt + marginCell*float64(len(lines))
-	//		if h > height {
-	//			height = h
-	//		}
-	//	}
-	//	//// add a new page if the height of the row doesn't fit on the page
-	//	//if pdf.GetY()+height > pageh-mbottom {
-	//	//	pdf.AddPage()
-	//	//	y = pdf.GetY()
-	//	//}
-	//	for i, txt := range row {
-	//		width := cols[i]
-	//		if len(txt) == 0 {
-	//			height = lineHt + marginCell
-	//		}
-	//		pdf.Rect(x, y, width, height, "")
-	//		pdf.MultiCell(width, lineHt+marginCell, txt, "", "CM", false)
-	//		x += width
-	//		pdf.SetXY(x, y)
-	//	}
-	//
-	//	pdf.SetXY(curx, y+height)
-	//}
-
-	for _, row := range rows {
-		curx, y = pdf.GetXY()
-		x := curx
-
-		height := 0.
-		_, lineHt := pdf.GetFontSize()
-
-		for i, txt := range row {
-			lines := pdf.SplitLines([]byte(txt), cols[i])
-			h = float64(len(lines))*lineHt + marginCell*float64(len(lines))
-			if h > height {
-				height = h
-			}
-		}
-		// add a new page if the height of the row doesn't fit on the page
-		if pdf.GetY()+height > pageh-mbottom {
-			pdf.AddPage()
-			y = pdf.GetY()
-		}
-		for i, txt := range row {
-			width := cols[i]
-			pdf.Rect(x, y, width, height, "")
-
-			pdf.MultiCell(width, lineHt+marginCell, txt, "", "C", false)
-			x += width
-			pdf.SetXY(x, y)
-		}
-		pdf.SetXY(curx, y+height)
-	}
-
-	y += 20
-	pdf.Text(curx, y, "运输温度记录:")
-	y += 3
-	pdf.SetXY(curx, y)
-	header2 := []string{"", "日期/时间", "储存温度", "冰排状态", "环境温度"}
-	cols2 := []float64{20, 77, 34, 34, 30}
-	h = 10.0
-	for i := 0; i < len(header2); i++ {
-		pdf.CellFormat(cols2[i], h, header2[i], "1", 0, "CM", false, 0, "")
-	}
-	pdf.Ln(-1)
-	y = pdf.GetY()
-	pdf.SetXY(curx, y)
-
-	row2 := [][]string{
-		{"启运", "______年___月___日___时___分", "________℃", "", "________℃"},
-		{"途中", "______年___月___日___时___分", "________℃", "————", "________℃"},
-		{"到达", "______年___月___日___时___分", "________℃", "", "________℃"},
-	}
-
-	for j, row := range row2 {
-		curx, y = pdf.GetXY()
-		x := curx
-		_, lineHt := pdf.GetFontSize()
-		height := lineHt * 3
-		if j == 1 {
-			height = lineHt * 5
-		}
-
-		// add a new page if the height of the row doesn't fit on the page
-		if pdf.GetY()+height > pageh-mbottom {
-			pdf.AddPage()
-			y = pdf.GetY()
-		}
-		for i, txt := range row {
-			width := cols2[i]
-			txtWd := pdf.GetStringWidth(txt)
-
-			txtX := x + (width-txtWd)/2
-
-			if j == 1 {
-				if i == 1 || i == 2 || i == 4 {
-					txtY := y + height/5*2
-					pdf.Text(txtX, txtY, txt)
-					txtY = y + height/5*4
-					pdf.Text(txtX, txtY, txt)
-				} else {
-					txtY := y + height/5*3
-					pdf.Text(txtX, txtY, txt)
-				}
-			} else {
-				txtY := y + height/3*2
-				pdf.Text(txtX, txtY, txt)
-			}
-
-			pdf.Rect(x, y, width, height, "")
-
-			x += width
-			pdf.SetXY(x, y)
-		}
-		pdf.SetXY(curx, y+height)
-	}
-	curx, y = pdf.GetXY()
-	y += 3
-	pdf.SetXY(curx, y)
-	pdf.CellFormat(0, 10, "启运至到达行驶里程数:_________千米", "", 0, "", false, 0, "")
-
-	y = pdf.GetY()
-	y += 8
-	pdf.SetXY(curx, y)
-	txtWd := pdf.GetStringWidth("发货单位:")
-	pdf.CellFormat(txtWd, 10, "发货单位:", "", 0, "", false, 0, "")
-	pdf.SetFont("simsun", "U", 9)
-	pdf.SetUnderlineThickness(2)
-	txtWd = pdf.GetStringWidth(beegouser.GetDeptName(c.Ctx))
-	pdf.CellFormat(txtWd, 10, beegouser.GetDeptName(c.Ctx), "", 0, "", false, 0, "")
-
-	pdf.SetXY(120, y)
-	pdf.SetFont("simsun", "", 9)
-	pdf.CellFormat(0, 10, "发货人签名:___________________________", "", 0, "", false, 0, "")
-
-	y = pdf.GetY()
-	y += 8
-	pdf.SetXY(curx, y)
-	txtWd = pdf.GetStringWidth("收货单位:")
-	pdf.CellFormat(txtWd, 10, "收货单位:", "", 0, "", false, 0, "")
-	pdf.SetFont("simsun", "U", 9)
-	pdf.SetUnderlineThickness(2)
-	txtWd = pdf.GetStringWidth(reqData.ReceivingUnit)
-	pdf.CellFormat(txtWd, 10, reqData.ReceivingUnit, "", 0, "", false, 0, "")
-
-	pdf.SetXY(120, y)
-	pdf.SetFont("simsun", "", 9)
-	pdf.CellFormat(0, 10, "收货人签名:___________________________", "", 0, "", false, 0, "")
-
-	y = pdf.GetY()
-	y += 10
-	pdf.SetXY(curx, y)
-	txt := "填表说明:本表供疫苗配送企业、疾病预防控制机构、接种单位疫苗运输时填写;出入库单号为单位编码+年月日+2位流水号;运输超过6小时需记录途中温度,间隔不超过6小时;使用无自动温度显示的冰排保冷设备时,只在启运和达到时填写冰排状态(冻结、冰水混合物、完全融化)。"
-	pdf.MultiCell(0, 5, txt, "", "", false)
-	pdf.Ln(-1)
-
-	pdf.SetFooterFunc(func() {
-		// Position at 1.5 cm from bottom
-		pdf.SetY(-15)
-		// Arial italic 8
-		pdf.SetFont("simsun", "", 8)
-		// Text color in gray
-		//pdf.SetTextColor(128, 128, 128)
-		// Page number
-		pdf.CellFormat(0, 10, fmt.Sprintf("第 %d 页 / 共 %d 页", pdf.PageNo(), pdf.PageCount()),
-			"", 0, "C", false, 0, "")
-	})
-	filename := "运输记录表" + time.Now().Format("20060102150405") + ".pdf"
-	// 保存文件
-	if err = pdf.OutputFileAndClose("ofile/" + filename); err != nil {
-		fmt.Println(err)
-	}
-	defer func() {
-		os.Remove("ofile/" + filename)
-		//os.Remove(imgPath)
-	}()
-
-	// 返回生成的 Excel 文件
-	c.Ctx.Output.Download("ofile/" + filename)
-
-}
-
 func getImageBytes(filePath string) []byte {
 	b, err := os.ReadFile(filePath)
 	if err != nil {

+ 0 - 3
go.mod

@@ -14,7 +14,6 @@ require (
 	github.com/go-sql-driver/mysql v1.7.0
 	github.com/gobwas/glob v0.2.3
 	github.com/google/uuid v1.3.0
-	github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5
 	github.com/ser163/png2j v0.1.2-beta
 	github.com/signintech/gopdf v0.20.0
 	github.com/smartystreets/goconvey v1.8.1
@@ -113,5 +112,3 @@ require (
 )
 
 replace gogs.baozhida.cn/zoie/OAuth-core => /Users/zoie/work/bzd_project/OAuth-core
-
-replace github.com/jung-kurt/gofpdf => /Users/zoie/work/bzd_project/github.com/jung-kurt/gofpdf

+ 1 - 3
go.sum

@@ -376,6 +376,7 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
+github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
@@ -488,7 +489,6 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP
 github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw=
 github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI=
 github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM=
-github.com/phpdave11/gofpdi v1.0.7/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
 github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 h1:zyWXQ6vu27ETMpYsEMAsisQ+GqJ4e1TPvSNfdOPF0no=
 github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
 github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
@@ -550,7 +550,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
 github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
 github.com/ser163/png2j v0.1.2-beta h1:ri7e+tGw/Y1TV18x8O4uONqaHjyTv/L2rnI3Ft5bMeA=
@@ -689,7 +688,6 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
 golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
 golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
 golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
-golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
 golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo=
 golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8=
 golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

+ 2 - 2
services/stock_template.go

@@ -1742,7 +1742,7 @@ func (e *StockTemplate) StockHomeStat(deptId int) (list map[string]interface{},
 	}
 
 	err = db.DB.Table("stock_in").
-		Select("SUM(stock_in.quantity * "+mtable+".unit_price)").
+		Select("COALESCE(SUM(stock_in.quantity * "+mtable+".unit_price),0)").
 		Joins("join "+mtable+" on stock_in.medicine_id = "+mtable+".id").
 		Where("dept_id = ? ", deptId).
 		Scan(&totalInMoney).Error
@@ -1758,7 +1758,7 @@ func (e *StockTemplate) StockHomeStat(deptId int) (list map[string]interface{},
 	}
 
 	err = db.DB.Table("stock_out").
-		Select("SUM(stock_out.quantity * "+mtable+".unit_price)").
+		Select("COALESCE(SUM(stock_out.quantity * "+mtable+".unit_price),0)").
 		Joins("join "+mtable+" on stock_out.medicine_id = "+mtable+".id").
 		Where("dept_id = ? ", deptId).
 		Scan(&totalOutMoney).Error