|
@@ -1654,7 +1654,6 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
minHumidityTime = data.T_time
|
|
|
}
|
|
|
totalHumidity += data.T_rh
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 平均温度
|
|
@@ -1681,6 +1680,7 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
|
|
|
pdf.SetMargins(0, 20, 0, 20)
|
|
|
pdf.AddPage()
|
|
|
+ var fileName2 string
|
|
|
if len(company.Logo) > 0 {
|
|
|
imgH, errImg := lib.GetImage(company.Logo)
|
|
|
if errImg != nil {
|
|
@@ -1711,7 +1711,7 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
err = pdf.Image(fileName, 10, 0, &gopdf.Rect{W: W, H: H})
|
|
|
if err != nil {
|
|
|
if err.Error() == "16-bit depth not supported" {
|
|
|
- fileName2 := "./ofile/" + time.Now().Format("20060102150405") + ".png"
|
|
|
+ fileName2 = "./ofile/" + time.Now().Format("20060102150405") + ".png"
|
|
|
f2, _ := os.Create(fileName2)
|
|
|
defer f.Close()
|
|
|
defer func() {
|
|
@@ -1829,7 +1829,7 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
y += 15
|
|
|
pdf.SetXY(10, y)
|
|
|
T_remark_temp := []rune(waybill.Remark)
|
|
|
- if len(waybill.Remark) > 35 {
|
|
|
+ if len(T_remark_temp) > 35 {
|
|
|
pdf.Text(fmt.Sprintf("备注:%s", string(T_remark_temp[0:35])))
|
|
|
pdf.SetXY(10, y+15)
|
|
|
pdf.Text(fmt.Sprintf("%s", string(T_remark_temp[35:])))
|
|
@@ -1883,18 +1883,12 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
y += 10
|
|
|
pdf.SetFont("wts", "", 10)
|
|
|
|
|
|
- var x float64 = 19
|
|
|
- var w float64 = 112
|
|
|
+ var x float64 = 12
|
|
|
+ var w float64 = 110
|
|
|
lib.RectFillColor(pdf, "时间", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
- w = 37
|
|
|
- lib.RectFillColor(pdf, "T1", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
- x = x + w
|
|
|
- lib.RectFillColor(pdf, "T2", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
-
|
|
|
- x = x + w
|
|
|
- w = 112
|
|
|
- lib.RectFillColor(pdf, "时间", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ w = 100
|
|
|
+ lib.RectFillColor(pdf, "名称", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
w = 37
|
|
|
lib.RectFillColor(pdf, "T1", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
@@ -1902,49 +1896,50 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
lib.RectFillColor(pdf, "T2", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
|
|
|
x = x + w
|
|
|
- w = 112
|
|
|
+ w = 110
|
|
|
lib.RectFillColor(pdf, "时间", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
+ w = 100
|
|
|
+ lib.RectFillColor(pdf, "名称", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ x = x + w
|
|
|
w = 37
|
|
|
lib.RectFillColor(pdf, "T1", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
lib.RectFillColor(pdf, "T2", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
|
|
|
+
|
|
|
for i, v := range Pdf_data {
|
|
|
- if i%3 == 0 {
|
|
|
+ if i%2 == 0 {
|
|
|
y += 20
|
|
|
var textH float64 = 25 // if text height is 25px.
|
|
|
pdf.SetNewY(y, textH)
|
|
|
y = pdf.GetY()
|
|
|
- x, w = 19, 112
|
|
|
+ x, w = 12, 110
|
|
|
lib.RectFillColor(pdf, v.T_time, 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
- w = 37
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id1), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
- x = x + w
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id2), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
- }
|
|
|
- if i%3 == 1 {
|
|
|
- x = x + w
|
|
|
- w = 112
|
|
|
- lib.RectFillColor(pdf, v.T_time, 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ w = 100
|
|
|
+ lib.RectFillColor(pdf, v.T_name, 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
w = 37
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id1), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ lib.RectFillColor(pdf, lib.Float32_to_string_forPDF(v.T_id1), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id2), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ lib.RectFillColor(pdf, lib.Float32_to_string_forPDF(v.T_id2), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
}
|
|
|
- if i%3 == 2 {
|
|
|
+ if i%2 == 1 {
|
|
|
x = x + w
|
|
|
- w = 112
|
|
|
+ w = 110
|
|
|
lib.RectFillColor(pdf, v.T_time, 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
+ w = 100
|
|
|
+ lib.RectFillColor(pdf, v.T_name,12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ x = x + w
|
|
|
w = 37
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id1), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ lib.RectFillColor(pdf, lib.Float32_to_string_forPDF(v.T_id1), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
x = x + w
|
|
|
- lib.RectFillColor(pdf, lib.Float32_to_string(&v.T_id2), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
+ lib.RectFillColor(pdf, lib.Float32_to_string_forPDF(v.T_id2), 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
filename = "运单" + waybill.WaybillNo + "温度记录" + time.Now().Format("20060102150405") + ".pdf"
|
|
|
filePath = "ofile/" + filename
|
|
@@ -1955,6 +1950,8 @@ func PDF(s service.Waybill, waybill model.Waybill, company model.SysDept, humidi
|
|
|
}
|
|
|
defer func() {
|
|
|
os.Remove(tempFilepath)
|
|
|
+ os.Remove(fileName2)
|
|
|
+
|
|
|
}()
|
|
|
return filename, filePath, nil
|
|
|
}
|
|
@@ -2562,25 +2559,29 @@ func DeviceDataTemperatureJPG3(startTime, endTime string, waybillPDF []service.W
|
|
|
})
|
|
|
series := make([]chart.Series, 0)
|
|
|
// 创建温度线
|
|
|
- xValues := make([]time.Time, len(deviceDataPdfList))
|
|
|
+ xValues1 := make([]time.Time, len(deviceDataPdfList))
|
|
|
+ xValues2 := make([]time.Time, 0)
|
|
|
yValues1 := make([]float64, len(deviceDataPdfList))
|
|
|
|
|
|
yValues2 := make([]float64, len(deviceDataPdfList))
|
|
|
for i := 0; i < len(deviceDataPdfList); i++ {
|
|
|
t, _ := lib.TimeStrToTime(deviceDataPdfList[i].T_time)
|
|
|
- xValues[i] = t
|
|
|
- yValues1[i] = float64(deviceDataPdfList[i].T_id1)
|
|
|
+ xValues1[i] = t
|
|
|
+ yValues1[i] = float64(*deviceDataPdfList[i].T_id1)
|
|
|
|
|
|
- yValues2[i] = float64(deviceDataPdfList[i].T_id2)
|
|
|
+ if deviceDataPdfList[i].T_id2 != nil {
|
|
|
+ xValues2 = append(xValues2, t)
|
|
|
+ yValues2[i] = float64(*deviceDataPdfList[i].T_id2)
|
|
|
+ }
|
|
|
}
|
|
|
series = append(series, chart.TimeSeries{
|
|
|
Name: "T1",
|
|
|
- XValues: xValues,
|
|
|
+ XValues: xValues1,
|
|
|
YValues: yValues1,
|
|
|
})
|
|
|
series = append(series, chart.TimeSeries{
|
|
|
Name: "T2",
|
|
|
- XValues: xValues,
|
|
|
+ XValues: xValues2,
|
|
|
YValues: yValues2,
|
|
|
})
|
|
|
if ymax < TemperatureMax {
|
|
@@ -2939,15 +2940,18 @@ func DeviceDataHumidityJPG3(startTime, endTime string, waybillPDF []service.Wayb
|
|
|
xValues1 := make([]time.Time, len(deviceDataPdfList))
|
|
|
yValues1 := make([]float64, len(deviceDataPdfList))
|
|
|
|
|
|
- xValues2 := make([]time.Time, len(deviceDataPdfList))
|
|
|
+ xValues2 := make([]time.Time, 0)
|
|
|
yValues2 := make([]float64, len(deviceDataPdfList))
|
|
|
for i := 0; i < len(deviceDataPdfList); i++ {
|
|
|
t, _ := lib.TimeStrToTime(deviceDataPdfList[i].T_time)
|
|
|
xValues1[i] = t
|
|
|
- yValues1[i] = float64(deviceDataPdfList[i].T_id1)
|
|
|
+ yValues1[i] = float64(*deviceDataPdfList[i].T_id1)
|
|
|
+
|
|
|
+ if deviceDataPdfList[i].T_id2 != nil {
|
|
|
+ xValues2 = append(xValues2, t)
|
|
|
+ yValues2[i] = float64(*deviceDataPdfList[i].T_id2)
|
|
|
+ }
|
|
|
|
|
|
- xValues2[i] = t
|
|
|
- yValues2[i] = float64(deviceDataPdfList[i].T_id2)
|
|
|
}
|
|
|
series = append(series, chart.TimeSeries{
|
|
|
Name: "T1",
|