|
@@ -546,7 +546,7 @@ func (c StockTemplateController) StockTemplateInventoryExcel(reqData dto.StockTe
|
|
|
// 返回生成的 Excel 文件
|
|
|
c.Ctx.Output.Download("ofile/" + filename)
|
|
|
}
|
|
|
-func (c StockTemplateController) StockTemplateInventoryPdf(reqData dto.StockTemplateInventoryExcelReq) {
|
|
|
+func (c StockTemplateController) StockTemplateInventoryPdf1(reqData dto.StockTemplateInventoryExcelReq) {
|
|
|
s := services.StockTemplate{}
|
|
|
deptId := beegouser.GetDeptId(c.Ctx)
|
|
|
models.InitBasicData(deptId)
|
|
@@ -764,6 +764,176 @@ func (c StockTemplateController) StockTemplateInventoryPdf(reqData dto.StockTemp
|
|
|
// 返回生成的 Excel 文件
|
|
|
c.Ctx.Output.Download("ofile/" + filename)
|
|
|
}
|
|
|
+func (c StockTemplateController) StockTemplateInventoryPdf(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}
|
|
|
+ cols := []float64{58, 73, 59, 53, 53, 35, 65, 59, 40}
|
|
|
+ cols1 := []float64{58, 73, 59, 53, 53, 35, 65, 59, 35, 65, 59, 35, 65, 59, 40}
|
|
|
+
|
|
|
+ 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]))
|
|
|
+ temp = append(temp, fmt.Sprintf("%s", row[models.FieldApprovalNumber]))
|
|
|
+ if row[models.FieldQualificationNumber] != nil {
|
|
|
+ temp = append(temp, fmt.Sprintf("%s", row[models.FieldQualificationNumber]))
|
|
|
+ } else {
|
|
|
+ temp = append(temp, "")
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 := &gopdf.GoPdf{}
|
|
|
+ pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 841.89, H: 595.28}})
|
|
|
+ pdf.SetMarginTop(20)
|
|
|
+ pdf.SetMarginBottom(40)
|
|
|
+
|
|
|
+ pdf.AddPage()
|
|
|
+ pdf.AddTTFFont("simsun", "static/fonts/MiSans-Medium.ttf")
|
|
|
+ pdf.SetFont("simsun", "", 22)
|
|
|
+ titleStr := "收发登记表"
|
|
|
+
|
|
|
+ titleWd, _ := pdf.MeasureTextWidth(titleStr)
|
|
|
+ pdf.SetX((842 / 2) - (titleWd / 2))
|
|
|
+ pdf.SetY(70)
|
|
|
+ pdf.Text(titleStr)
|
|
|
+
|
|
|
+ pdf.SetFont("simsun", "", 10)
|
|
|
+ x := 20.
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ x += cols1[i]
|
|
|
+ }
|
|
|
+ pdf.SetXY(x, 90)
|
|
|
+ pdf.Text(fmt.Sprintf("制品名称:%s 编号", productName))
|
|
|
+ pdf.SetXY(x, 110)
|
|
|
+ pdf.Text(fmt.Sprintf("剂型:%s 规格:%s 单位:%s", dosageFormName, specName, unitName))
|
|
|
+
|
|
|
+ curx := 16.
|
|
|
+ header := []string{"日期", "购货/发货单位", "生产企业", "批准文号", "批签发合格证编号", "收入", "支出", "结余", "经办人签字"}
|
|
|
+ h := 50.0
|
|
|
+ pdf.SetFont("simsun", "", 11)
|
|
|
+ x = curx
|
|
|
+ y := 116.
|
|
|
+
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ for i := 0; i < len(header); i++ {
|
|
|
+ utils.RectFillColorMultiCell(pdf, header[i], 11, x, y, cols[i], h, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ if header[i] == "收入" || header[i] == "支出" || header[i] == "结余" {
|
|
|
+ utils.RectFillColorMultiCell(pdf, header[i], 11, x, y, cols[5]+cols[6]+cols[7], h/2, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ utils.RectFillColorMultiCell(pdf, "数量", 11, x, y+h/2, cols[5], h/2, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ utils.RectFillColorMultiCell(pdf, "批号", 11, x+cols[5], y+h/2, cols[6], h/2, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ utils.RectFillColorMultiCell(pdf, "效期", 11, x+cols[5]+cols[6], y+h/2, cols[7], h/2, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ x += cols[5] + cols[6] + cols[7]
|
|
|
+ } else {
|
|
|
+ x += cols[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pdf.SetFont("simsun", "", 10)
|
|
|
+ y += h
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ h = 20.0
|
|
|
+ for _, row := range rows {
|
|
|
+ y = pdf.GetY()
|
|
|
+ x = curx
|
|
|
+
|
|
|
+ height := h
|
|
|
+
|
|
|
+ for j, txt := range row {
|
|
|
+ lineTexts, _ := pdf.SplitText(txt, cols1[j])
|
|
|
+ if len(lineTexts) > 1 {
|
|
|
+ lineTexts, _ = pdf.SplitText(txt, cols1[j]-4)
|
|
|
+ lineHt := h * float64(len(lineTexts)) * 0.8
|
|
|
+ if lineHt > height {
|
|
|
+ height = lineHt
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, txt := range row {
|
|
|
+ width := cols1[i]
|
|
|
+ utils.RectFillColorMultiCell(pdf, txt, 9, x, y, width, height, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ x += width
|
|
|
+ }
|
|
|
+ pdf.SetNewY(y+height, height)
|
|
|
+ }
|
|
|
+
|
|
|
+ filename := "收发登记表" + time.Now().Format("20060102150405") + ".pdf"
|
|
|
+ // 保存文件
|
|
|
+ if err := pdf.WritePdf("ofile/" + filename); err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ os.Remove("ofile/" + filename)
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 返回生成的 Excel 文件
|
|
|
+ c.Ctx.Output.Download("ofile/" + filename)
|
|
|
+}
|
|
|
func (c StockTemplateController) StockTemplateInventoryExport() {
|
|
|
reqData := dto.StockTemplateInventoryExcelReq{}
|
|
|
if err := c.ParseAndValidate(&c.Ctx.Input.RequestBody, &reqData); err != nil {
|
|
@@ -1050,7 +1220,9 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
|
|
|
run = para.AddRun()
|
|
|
run.Properties().SetFontFamily("宋体")
|
|
|
run.Properties().SetSize(8)
|
|
|
- run.AddText(medicineInfo[models.FieldQualificationNumber].(string))
|
|
|
+ if medicineInfo[models.FieldQualificationNumber] != nil {
|
|
|
+ run.AddText(medicineInfo[models.FieldQualificationNumber].(string))
|
|
|
+ }
|
|
|
|
|
|
cell = row.AddCell()
|
|
|
cell.Properties().SetWidthPercent(13)
|
|
@@ -1111,7 +1283,7 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
|
|
|
run = para.AddRun()
|
|
|
run.Properties().SetFontFamily("宋体")
|
|
|
run.Properties().SetSize(8)
|
|
|
- unitName := models.Read_Enterprise_Get(utils.ToInt(medicineInfo[models.FieldUnitID]))
|
|
|
+ unitName := models.Read_Unit_Get(utils.ToInt(medicineInfo[models.FieldUnitID]))
|
|
|
run.AddText(unitName)
|
|
|
}
|
|
|
|
|
@@ -1729,7 +1901,7 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
|
|
|
c.Ctx.Output.Download("ofile/" + filename)
|
|
|
}
|
|
|
|
|
|
-func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordWordReq) {
|
|
|
+func (c StockTemplateController) TransportRecordPdf1(reqData dto.TransportRecordWordReq) {
|
|
|
s := services.StockTemplate{}
|
|
|
deptId := beegouser.GetDeptId(c.Ctx)
|
|
|
|
|
@@ -1739,7 +1911,7 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- cols := []float64{30, 22, 20, 27, 31, 22, 21, 11, 11}
|
|
|
+ cols := []float64{30, 22, 22, 27, 31, 22, 21, 11, 11}
|
|
|
|
|
|
header := []string{"品种", "生产企业", "批准文号", "批签发合格编号", "规格(剂/支或粒)", "批号", "失效日期", "数量", "单位"}
|
|
|
rows := [][]string{}
|
|
@@ -1748,7 +1920,12 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
|
|
|
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]))
|
|
|
- temp = append(temp, fmt.Sprintf("%s", row[models.FieldQualificationNumber]))
|
|
|
+ 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])))
|
|
@@ -1806,12 +1983,45 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
|
|
|
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()
|
|
|
- if y > pageh-mbottom-marginCell {
|
|
|
- pdf.AddPage()
|
|
|
- y = pdf.GetY()
|
|
|
- }
|
|
|
x := curx
|
|
|
|
|
|
height := 0.
|
|
@@ -1824,22 +2034,19 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
|
|
|
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()
|
|
|
- //}
|
|
|
+ // 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)
|
|
|
+
|
|
|
+ pdf.MultiCell(width, lineHt+marginCell, txt, "", "C", false)
|
|
|
x += width
|
|
|
pdf.SetXY(x, y)
|
|
|
}
|
|
|
-
|
|
|
pdf.SetXY(curx, y+height)
|
|
|
}
|
|
|
|
|
@@ -1969,6 +2176,288 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
|
|
|
c.Ctx.Output.Download("ofile/" + filename)
|
|
|
|
|
|
}
|
|
|
+func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordWordReq) {
|
|
|
+ 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{83, 50, 55, 72, 72, 50, 66, 50, 27, 30}
|
|
|
+
|
|
|
+ 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", utils.ToDate(row[models.FieldProducedDate])))
|
|
|
+ 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 := &gopdf.GoPdf{}
|
|
|
+ pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}})
|
|
|
+ pdf.SetMarginTop(40)
|
|
|
+ pdf.SetMarginBottom(40)
|
|
|
+
|
|
|
+ pdf.AddPage()
|
|
|
+ pdf.AddTTFFont("simsun", "static/fonts/MiSans-Medium.ttf")
|
|
|
+ pdf.SetFont("simsun", "", 22)
|
|
|
+
|
|
|
+ pdf.SetMargins(2, 5, 5, 5)
|
|
|
+
|
|
|
+ titleStr := "表3-4 运输记录表"
|
|
|
+ textw, _ := pdf.MeasureTextWidth(titleStr)
|
|
|
+ pdf.SetX((595 / 2) - (textw / 2))
|
|
|
+ pdf.SetY(40)
|
|
|
+ pdf.Text(titleStr)
|
|
|
+
|
|
|
+ pdf.SetFont("simsun", "", 16)
|
|
|
+ titleStr = "(各级通用)"
|
|
|
+ textw, _ = pdf.MeasureTextWidth(titleStr)
|
|
|
+ pdf.SetX((595 / 2) - (textw / 2))
|
|
|
+ pdf.SetY(60)
|
|
|
+ pdf.Text(titleStr)
|
|
|
+
|
|
|
+ pdf.SetFont("simsun", "", 10)
|
|
|
+ curx, y := 20., pdf.GetY()
|
|
|
+ y += 25
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ pdf.Text("运输工具: □冷藏车 □运输车 □普通车辆 □无 □其他")
|
|
|
+ y += 16
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ pdf.Text("冷藏工具: □冷藏车 □车载冷藏箱 □冷藏箱或冷藏包 □其他")
|
|
|
+ y += 16
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ pdf.Text("配送方式: □本级配送(车牌号:_______) □下级自运(车牌号:_______)")
|
|
|
+
|
|
|
+ y += 20
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ pdf.Text("运输情况:")
|
|
|
+ y += 6
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ h := 20.0
|
|
|
+ x := curx
|
|
|
+ pdf.SetFont("simsun", "", 9)
|
|
|
+ for i := 0; i < len(header); i++ {
|
|
|
+ utils.RectFillColor(pdf, header[i], 9, x, y, cols[i], h, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ x += cols[i]
|
|
|
+ }
|
|
|
+ y += h
|
|
|
+ pdf.SetXY(curx, y)
|
|
|
+ pdf.SetFont("simsun", "", 8)
|
|
|
+
|
|
|
+ for _, row := range rows {
|
|
|
+ curx, y = pdf.GetX(), pdf.GetY()
|
|
|
+ x = curx
|
|
|
+
|
|
|
+ height := h
|
|
|
+ for i, txt := range row {
|
|
|
+ lineTexts, _ := pdf.SplitText(txt, cols[i])
|
|
|
+ //lineHt := h * float64(len(lineTexts))
|
|
|
+ if len(lineTexts) > 1 {
|
|
|
+ lineTexts, _ = pdf.SplitText(txt, cols[i]-4)
|
|
|
+ lineHt := h * float64(len(lineTexts)) * 0.6
|
|
|
+ if lineHt > height {
|
|
|
+ height = lineHt
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, txt := range row {
|
|
|
+ width := cols[i]
|
|
|
+ utils.RectFillColorMultiCell(pdf, txt, 9, x, y, width, height, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ x += width
|
|
|
+ }
|
|
|
+ pdf.SetNewY(y+height, height)
|
|
|
+ pdf.SetX(curx)
|
|
|
+ }
|
|
|
+ pdf.SetFont("simsun", "", 9)
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 20
|
|
|
+ pdf.SetNewY(y, 20)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ pdf.Text("运输温度记录:")
|
|
|
+ header2 := []string{"", "日期/时间", "储存温度", "冰排状态", "环境温度"}
|
|
|
+ cols2 := []float64{55, 210, 105, 94, 91}
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 5
|
|
|
+ h = 35.0
|
|
|
+ pdf.SetNewY(y, h)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ y = pdf.GetY()
|
|
|
+ pdf.SetX(curx)
|
|
|
+ x = curx
|
|
|
+ for i := 0; i < len(header2); i++ {
|
|
|
+ utils.RectFillColor(pdf, header2[i], 9, x, y, cols2[i], h, 0, 0, 0, gopdf.Center, gopdf.Middle)
|
|
|
+ x += cols2[i]
|
|
|
+ }
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += h
|
|
|
+ pdf.SetNewY(y, h)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ row2 := [][]string{
|
|
|
+ {"启运", "______年___月___日___时___分", "________℃", "", "________℃"},
|
|
|
+ {"途中", "______年___月___日___时___分", "________℃", "————", "________℃"},
|
|
|
+ {"到达", "______年___月___日___时___分", "________℃", "", "________℃"},
|
|
|
+ }
|
|
|
+
|
|
|
+ for j, row := range row2 {
|
|
|
+ curx, y = pdf.GetX(), pdf.GetY()
|
|
|
+ x = curx
|
|
|
+ pdf.SetTextColor(0, 0, 0)
|
|
|
+
|
|
|
+ height := h
|
|
|
+ if j == 1 {
|
|
|
+ height = height * 2
|
|
|
+ }
|
|
|
+ for i, txt := range row {
|
|
|
+ width := cols2[i]
|
|
|
+ txtWd, _ := pdf.MeasureTextWidth(txt)
|
|
|
+
|
|
|
+ txtX := x + (width-txtWd)/2
|
|
|
+
|
|
|
+ pdf.SetLineWidth(0.8)
|
|
|
+ pdf.SetFillColor(255, 255, 255) //setup fill color
|
|
|
+ pdf.SetLineType("") // 线条样式
|
|
|
+ pdf.RectFromUpperLeftWithStyle(x, y, width, height, "FD")
|
|
|
+
|
|
|
+ if j == 1 {
|
|
|
+ if i == 1 || i == 2 || i == 4 {
|
|
|
+ txtY := y + height/5*2
|
|
|
+ pdf.SetXY(txtX, txtY)
|
|
|
+ pdf.Text(txt)
|
|
|
+ txtY = y + height/5*4
|
|
|
+ pdf.SetXY(txtX, txtY)
|
|
|
+ pdf.Text(txt)
|
|
|
+ } else {
|
|
|
+ txtY := y + height/5*3
|
|
|
+ pdf.SetXY(txtX, txtY)
|
|
|
+ pdf.Text(txt)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ txtY := y + height/3*2
|
|
|
+ pdf.SetXY(txtX, txtY)
|
|
|
+ pdf.Text(txt)
|
|
|
+ }
|
|
|
+
|
|
|
+ x += width
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ pdf.SetNewY(y+height,height)
|
|
|
+
|
|
|
+ if pdf.GetY() < 30 || pdf.GetY() > 810 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ }
|
|
|
+
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 20
|
|
|
+ pdf.SetNewY(y, 20)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ pdf.Text("启运至到达行驶里程数:_________千米")
|
|
|
+
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 25
|
|
|
+ pdf.SetNewY(y, 25)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ y = pdf.GetY()
|
|
|
+ pdf.Text("发货单位:")
|
|
|
+ txtWd, _ := pdf.MeasureTextWidth("发货单位:")
|
|
|
+ pdf.SetLineWidth(0.8)
|
|
|
+ pdf.SetXY(curx+txtWd, y)
|
|
|
+ pdf.Text(beegouser.GetDeptName(c.Ctx))
|
|
|
+ pdf.Line(57, y+3, 207, y+3)
|
|
|
+
|
|
|
+ pdf.SetXY(300, y)
|
|
|
+ pdf.Text("发货人签名:")
|
|
|
+ txtWd, _ = pdf.MeasureTextWidth("发货人签名:")
|
|
|
+ pdf.Line(345, y+3, 495, y+3)
|
|
|
+
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 25
|
|
|
+ pdf.SetNewY(y, 25)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ y = pdf.GetY()
|
|
|
+ pdf.Text("收货单位:")
|
|
|
+ txtWd, _ = pdf.MeasureTextWidth("收货单位:")
|
|
|
+ pdf.SetXY(curx+txtWd, y)
|
|
|
+ pdf.Text(beegouser.GetDeptName(c.Ctx))
|
|
|
+ pdf.Line(57, y+3, 207, y+3)
|
|
|
+
|
|
|
+ pdf.SetXY(300, y)
|
|
|
+ pdf.Text("收货人签名:")
|
|
|
+ txtWd, _ = pdf.MeasureTextWidth("收货人签名:")
|
|
|
+ pdf.Line(345, y+3, 495, y+3)
|
|
|
+
|
|
|
+ y = pdf.GetY()
|
|
|
+ y += 20
|
|
|
+ pdf.SetNewY(y, 20)
|
|
|
+ if pdf.GetY() < 30 {
|
|
|
+ pdf.SetY(30)
|
|
|
+ }
|
|
|
+ pdf.SetX(curx)
|
|
|
+ pdf.SetCharSpacing(0.5)
|
|
|
+ txt := "填表说明:本表供疫苗配送企业、疾病预防控制机构、接种单位疫苗运输时填写;出入库单号为单位编码+年月日+2位流水号;运输超过6小时需记录途中温度,间隔不超过6小时;使用无自动温度显示的冰排保冷设备时,只在启运和达到时填写冰排状态(冻结、冰水混合物、完全融化)。"
|
|
|
+ pdf.MultiCell(&gopdf.Rect{W: 555, H: 50}, txt)
|
|
|
+
|
|
|
+ pdf.AddFooter(func() {
|
|
|
+ pdf.SetY(y + 15)
|
|
|
+ pdf.Cell(nil, fmt.Sprintf("第 %d 页 / 共 %d 页", pdf.GetNumberOfPages(), pdf.GetNumberOfPages()))
|
|
|
+ })
|
|
|
+ filename := "运输记录表" + time.Now().Format("20060102150405") + ".pdf"
|
|
|
+ // 保存文件
|
|
|
+ if err = pdf.WritePdf("ofile/" + filename); err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ os.Remove("ofile/" + filename)
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 返回生成的 Excel 文件
|
|
|
+ c.Ctx.Output.Download("ofile/" + filename)
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
// TransportRecordExport 运输记录表
|
|
|
// @Summary 收发登记表word
|