|
|
@@ -1,8 +1,14 @@
|
|
|
package limsreportelecpumpwell
|
|
|
|
|
|
import (
|
|
|
+ "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"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
type LimsReportElecPumpWellService struct {
|
|
|
@@ -13,4 +19,92 @@ func GetLimsReportElecPumpWellService(xormEngine *xorm.Engine) *LimsReportElecPu
|
|
|
s := new(LimsReportElecPumpWellService)
|
|
|
s.DBE = xormEngine
|
|
|
return s
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 生成报告
|
|
|
+ */
|
|
|
+func (s *LimsReportElecPumpWellService) DataToExcelReport(entrustMainEntity limsentrust.LimsEntrustMain, dateentryname string, createreportname string,tablename string, seqStr string, retUrl string, entrustId string, dataentryIds string) (reportUrl string, err error) {
|
|
|
+ var reportList []LimsReportElecPumpWell
|
|
|
+ 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{})
|
|
|
+ rhoW := 1000.00
|
|
|
+ g := 9.8
|
|
|
+ limitval1 := 22.00
|
|
|
+ limitval2 := 0.72
|
|
|
+ fw := float64(reportList[0].WaterContent) // 含水率
|
|
|
+ rhoO := float64(reportList[0].CrudeOilDensity) // 原油密度
|
|
|
+ hye := float64(reportList[0].WorkingFluidLevel) // 动液面 H液
|
|
|
+ po := float64(reportList[0].OilPressure)// 油压 P油
|
|
|
+ pt := float64(reportList[0].CasingPressure)// 套压 P套
|
|
|
+ q := float64(reportList[0].ProducedFluidVolume)// 产液量 Q
|
|
|
+ pdr := float64(reportList[0].AvgActivePower)// 平均有功功率 P电入
|
|
|
+ cosphi := float64(reportList[0].AvgPowerFactor) //平均功率因数
|
|
|
+ lb := float64(reportList[0].RatedLift)//电泵额定扬程 L泵
|
|
|
+ qe := float64(reportList[0].RatedDischarge)//额定排量 Q额
|
|
|
+
|
|
|
+
|
|
|
+ rho,err := strconv.ParseFloat(fmt.Sprintf("%.3f",(1-fw/100)*rhoO+fw/100*rhoW),64) // 油井液体密度
|
|
|
+ var h float64
|
|
|
+ if (rho*g != 0) { // 有效扬程
|
|
|
+ h,err = strconv.ParseFloat(fmt.Sprintf("%.3f",hye+(po-pt)*1000000/(rho*g)),64)
|
|
|
+ } else {
|
|
|
+ h = 0.00
|
|
|
+ }
|
|
|
+
|
|
|
+ py,err := strconv.ParseFloat(fmt.Sprintf("%.3f",q*h*rho*g/86400000),64) // 有效功率
|
|
|
+ var etaxt float64
|
|
|
+ if (pdr != 0) {
|
|
|
+ etaxt,err = strconv.ParseFloat(fmt.Sprintf("%.3f",py/pdr*100),64) // 系统效率
|
|
|
+ } else {
|
|
|
+ etaxt = 0.00
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ datamap["fw"] = fw
|
|
|
+ datamap["rhoO"] = rhoO
|
|
|
+ datamap["hye"] = hye
|
|
|
+ datamap["po"] = po
|
|
|
+ datamap["pt"] = pt
|
|
|
+ datamap["q"] = q
|
|
|
+ datamap["pdr"] = pdr
|
|
|
+ datamap["cosphi"] = cosphi
|
|
|
+ datamap["lb"] = lb
|
|
|
+ datamap["qe"] = qe
|
|
|
+ datamap["h"] = cosphi
|
|
|
+ datamap["etaxt"] = etaxt
|
|
|
+
|
|
|
+ if (etaxt >= limitval1) {
|
|
|
+ datamap["result1"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["result1"] = "不合格"
|
|
|
+ }
|
|
|
+ if (cosphi >= limitval2) {
|
|
|
+ datamap["result2"] = "合格"
|
|
|
+ } else {
|
|
|
+ datamap["result2"] = "不合格"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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].PumpModel
|
|
|
+ //datamap["number"] = reportList[0].DeviceName
|
|
|
+ datamap["place"] = reportList[0].PositionCheck
|
|
|
+ datamap["instr"] = reportList[0].MonitoringInstrument
|
|
|
+ datamap["evalva1"] = 35
|
|
|
+ datamap["limitval1"] = limitval1
|
|
|
+ datamap["limitval2"] = limitval2
|
|
|
+ reportUrl = svcActiviti.FillWordTemplate(datamap, templateUrl, fileName)
|
|
|
+
|
|
|
+ return reportUrl, err
|
|
|
}
|