|
|
@@ -1,8 +1,15 @@
|
|
|
package limsreportliquidtransportation
|
|
|
|
|
|
import (
|
|
|
-. "dashoo.cn/backend/api/mydb"
|
|
|
-"github.com/go-xorm/xorm"
|
|
|
+ "dashoo.cn/backend/api/business/limsentrust"
|
|
|
+ "dashoo.cn/backend/api/business/workflow"
|
|
|
+ . "dashoo.cn/backend/api/mydb"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+ "fmt"
|
|
|
+ "github.com/go-xorm/xorm"
|
|
|
+ "math"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
type LimsReportLiquidTransportationService struct {
|
|
|
@@ -14,3 +21,127 @@ func GetLimsReportLiquidTransportationService(xormEngine *xorm.Engine) *LimsRepo
|
|
|
s.DBE = xormEngine
|
|
|
return s
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 生成报告
|
|
|
+ */
|
|
|
+func (s *LimsReportLiquidTransportationService) DataToExcelReport(entrustMainEntity limsentrust.LimsEntrustMain, dateentryname string, createreportname string, tablename string, seqStr string, retUrl string, entrustId string, dataentryIds string) (reportUrl string, err error) {
|
|
|
+ var reportList []LimsReportLiquidTransportation
|
|
|
+ s.GetEntitysByOrderbyWhere(tablename, "DataEntryId in ("+dataentryIds+")", "DataEntryId", &reportList)
|
|
|
+ //模板下载到服务器
|
|
|
+ //_dir := utils.Cfg.MustValue("file", "tmplateDir") + entrustId
|
|
|
+ fileurl := strings.Split(retUrl, "|")
|
|
|
+ templateUrl := "http://" + fileurl[0]
|
|
|
+ fileName := fileurl[1]
|
|
|
+
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+ datamap := make(map[string]interface{})
|
|
|
+ g := 9.8
|
|
|
+ limitval1 := 66.00
|
|
|
+ limitval2 := 46.00
|
|
|
+ limitval3 := 6.00
|
|
|
+ limitval4 := 0.87
|
|
|
+
|
|
|
+ pn := float64(reportList[0].MotorPower) // 电动机额定功率
|
|
|
+ qn := float64(reportList[0].Flow1) // 泵额定流量
|
|
|
+ q := float64(reportList[0].TrafficRecord / 3600) // 泵实际流量
|
|
|
+ pgr := float64(reportList[0].MotorPowerRecord) // 电机输入功率
|
|
|
+ c1 := float64(reportList[0].Inhalation / 1000) // 泵吸入管道周长
|
|
|
+ d1 := float64(reportList[0].Imported / 1000) // 壁厚
|
|
|
+ p1 := float64(reportList[0].PumpSuctionRecord * math.Pow(10, 6)) //压力
|
|
|
+ c2 := float64(reportList[0].Discharge / 1000) // 泵排出管道周长
|
|
|
+ d2 := float64(reportList[0].Exit / 1000) // 壁厚
|
|
|
+ p2 := float64(reportList[0].PumpDischargeRecord * math.Pow(10, 6)) //压力
|
|
|
+ c3 := float64(reportList[0].ThrottleValve / 1000) // 节阀后管道
|
|
|
+ d3 := float64(reportList[0].AfterValve / 1000) // 壁厚
|
|
|
+ p3 := float64(reportList[0].ThrottleRecord * math.Pow(10, 6)) //压力
|
|
|
+ z1 := float64(reportList[0].InhalationPressure / 1000) // 吸入压力测点距基准面
|
|
|
+ z2 := float64(reportList[0].DischargePressure / 1000) // 排出压力测点距基准面
|
|
|
+ z3 := float64(reportList[0].ThrottlePressure / 1000) // 节阀后压力测点距基准面
|
|
|
+ cosphi := float64(reportList[0].MotorFactorRecord)
|
|
|
+ rho := float64(reportList[0].LiquidDensity) // 液体密度
|
|
|
+ v1 := 0.00
|
|
|
+ v2 := 0.00
|
|
|
+ v3 := 0.00
|
|
|
+ if (math.Pow(c1/(2*math.Pi)-d3, 2) != 0) { // 泵吸入点流速
|
|
|
+ v1, err = strconv.ParseFloat(fmt.Sprintf("%.3f", q/math.Pow(c1/(2*math.Pi)-d1, 2)), 64)
|
|
|
+ } else {
|
|
|
+ v1 = 0.00
|
|
|
+ }
|
|
|
+ if (math.Pow(c2/(2*math.Pi)-d2, 2) != 0) { // 泵排出点流速
|
|
|
+ v2, err = strconv.ParseFloat(fmt.Sprintf("%.3f", q/math.Pow(c1/(2*math.Pi)-d2, 2)), 64)
|
|
|
+ } else {
|
|
|
+ v2 = 0.00
|
|
|
+ }
|
|
|
+ if (math.Pow(c3/(2*math.Pi)-d3, 2) != 0) { // 泵节阀后流速
|
|
|
+ v3, err = strconv.ParseFloat(fmt.Sprintf("%.3f", q/math.Pow(c1/(2*math.Pi)-d3, 2)), 64)
|
|
|
+ } else {
|
|
|
+ v3 = 0.00
|
|
|
+ }
|
|
|
+
|
|
|
+ h, err := strconv.ParseFloat(fmt.Sprintf("%.3f", p2-p1/(rho*g)+z2-z1+(v2*v2-v1*v1)/(2*g)), 64) // 总扬程
|
|
|
+ etag, err := strconv.ParseFloat(fmt.Sprintf("%.3f", rho*g*h*q*math.Pow(10, -3)/pgr/100), 64) // 泵机组效率
|
|
|
+ h1, err := strconv.ParseFloat(fmt.Sprintf("%.3f", (p2-p1)/rho*g+z2-z3+(v2*v2+v3+v3)/2*g), 64) // 调节阀引起的扬程损失
|
|
|
+ etasys, err := strconv.ParseFloat(fmt.Sprintf("%.3f", rho*g*(h-h1)*q*math.Pow(10, -3)/pgr/100), 64) // 泵机组系统效率
|
|
|
+ etaj := 0.00 // 节流损失率
|
|
|
+
|
|
|
+ datamap["pn "] = pn
|
|
|
+ datamap["qn"] = qn
|
|
|
+ datamap["q"] = q
|
|
|
+ datamap["pgr"] = pgr
|
|
|
+ datamap["c1"] = c1
|
|
|
+ datamap["d1"] = d1
|
|
|
+ datamap["p1"] = p1
|
|
|
+ datamap["c2"] = c2
|
|
|
+ datamap["d2"] = d2
|
|
|
+ datamap["p2"] = p2
|
|
|
+ datamap["c3"] = c3
|
|
|
+ datamap["d3"] = d3
|
|
|
+ datamap["p3"] = p3
|
|
|
+ datamap["z1"] = z1
|
|
|
+ datamap["z2"] = z2
|
|
|
+ datamap["z3"] = z3
|
|
|
+ datamap["v1"] = v1
|
|
|
+ datamap["v2"] = v2
|
|
|
+ datamap["v3"] = v3
|
|
|
+ datamap["h"] = h
|
|
|
+ datamap["etag"] = etag
|
|
|
+ datamap["h1"] = h1
|
|
|
+ datamap["etasys"] = etasys
|
|
|
+
|
|
|
+ if (etag >= limitval1) {
|
|
|
+ datamap["res1"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["res1"] = "不合格"
|
|
|
+ }
|
|
|
+ if (etasys >= limitval2) {
|
|
|
+ datamap["res2"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["res2"] = "不合格"
|
|
|
+ }
|
|
|
+ if (etaj >= limitval3) {
|
|
|
+ datamap["res3"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["res3"] = "不合格"
|
|
|
+ }
|
|
|
+ if (cosphi >= limitval4) {
|
|
|
+ datamap["res4"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["res4"] = "不合格"
|
|
|
+ }
|
|
|
+
|
|
|
+ datamap["code"] = seqStr
|
|
|
+ datamap["company"] = reportList[0].TestDepart
|
|
|
+ datamap["jcnum"] = reportList[0].CreateOn.Format("2006-01-02")
|
|
|
+ datamap["jcdate"] = reportList[0].CreateOn.Format("2006年01月02日")
|
|
|
+ datamap["spec"] = reportList[0].Model1
|
|
|
+ //datamap["number"] = reportList[0].DeviceName
|
|
|
+ datamap["place"] = reportList[0].InstalPosition
|
|
|
+ //datamap["instr"] = reportList[0].MonitoringInstrument
|
|
|
+ datamap["limit1"] = limitval1
|
|
|
+ datamap["limit2"] = limitval2
|
|
|
+ datamap["limit3"] = limitval3
|
|
|
+ reportUrl = svcActiviti.FillWordTemplate(datamap, templateUrl, fileName)
|
|
|
+
|
|
|
+ return reportUrl, err
|
|
|
+}
|