lining 7 anos atrás
pai
commit
f995a2fb99

+ 8 - 0
src/dashoo.cn/backend/api/business/codecsequence/codecsequenceService.go

@@ -443,4 +443,12 @@ func (s *CodecSequenceService)GetReportPistonPumpUnit(accCode string) string{
 	sequence := s.GetSequenceByName(accCode, seqName)
 	seqStr := "J能QP2.2-"+ strconv.Itoa(time.Now().Year()) + "-" + fmt.Sprintf("%03s", strconv.Itoa(sequence))
 	return seqStr
+}
+
+// 螺杆泵
+func (s *CodecSequenceService)GetReportScrewPump(accCode string) string{
+	seqName := "PistonScrewPump"
+	sequence := s.GetSequenceByName(accCode, seqName)
+	seqStr := "J能QC3.2-"+ strconv.Itoa(time.Now().Year()) + "-" + fmt.Sprintf("%03s", strconv.Itoa(sequence))
+	return seqStr
 }

+ 2 - 0
src/dashoo.cn/backend/api/business/limsdoctemplate/limstemplateenum.go

@@ -141,4 +141,6 @@ const (
 	DAYT_LIMSREPORTELECPUMPWELL_REPORT string = "DAYT.LimsReportElecPumpWell.Report"
 	// 柱塞泵机组
 	DAYT_REPORTPISTONPUMPUNIT_REPORT string = "DAYT.ReportPistonPumpUnit.Report"
+	// 螺杆泵节能监测报告
+	DAYT_LIMSREPORTSCREWPUMP_REPORT string = "DAYT.LimsReportScrewPump.Report"
 )

+ 91 - 0
src/dashoo.cn/backend/api/business/limsreportscrewpump/limsreportscrewpumpService.go

@@ -1,8 +1,14 @@
 package limsreportscrewpump
 
 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 LimsReportScrewPumpService struct {
@@ -15,3 +21,88 @@ func GetLimsReportScrewPumpService(xormEngine *xorm.Engine) *LimsReportScrewPump
 	return s
 }
 
+/**
+ * 生成报告
+ */
+func (s *LimsReportScrewPumpService) DataToExcelReport(entrustMainEntity limsentrust.LimsEntrustMain, dateentryname string, createreportname string,tablename string, seqStr string, retUrl string, entrustId string, dataentryIds string) (reportUrl string, err error) {
+	var reportList []LimsReportScrewPump
+	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.81
+	limitval1 := 23.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].SuctionDepth)//电泵额定扬程 L泵
+
+
+	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["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
+}

+ 11 - 5
src/dashoo.cn/backend/api/controllers/lims/limscreatereport.go

@@ -7,6 +7,7 @@ import (
 	"dashoo.cn/backend/api/business/limsreportdetHSgas"
 	"dashoo.cn/backend/api/business/limsreportdetelectoxygen"
 	"dashoo.cn/backend/api/business/limsreportpistonpumpunit"
+	"dashoo.cn/backend/api/business/limsreportscrewpump"
 	"encoding/base64"
 	"encoding/json"
 	"fmt"
@@ -996,11 +997,16 @@ func (this *CreateReportController) generateExcelReportN(entrustMain limsentrust
 		svc := limsreportelecpumpwell.GetLimsReportElecPumpWellService(utils.DBE)
 		reportUrl, err = svc.DataToExcelReport(entrustMain, this.User.AccCode+LimsDateEntryName, this.User.AccCode+LimsCreateReportName, this.User.AccCode+LimsReportElecPumpWellName, seqStr, docTemplate.FileURL, entrustId, dataentryIds)
 	case limsdoctemplate.DAYT_REPORTPISTONPUMPUNIT_REPORT:
-	codecSvc := codecsequence.GetCodecSequenceService(utils.DBE)
-	seqStr := codecSvc.GetReportPistonPumpUnit(this.User.AccCode)
-	fmt.Println(time.Now().Month())
-	svc := limsreportpistonpumpunit.GetLimsReportPistonPumpUnitService(utils.DBE)
-	reportUrl, err = svc.DataToExcelReport(entrustMain, this.User.AccCode+LimsDateEntryName, this.User.AccCode+LimsCreateReportName, this.User.AccCode+LimsReportPistonPumpUnitName, seqStr, docTemplate.FileURL, entrustId, dataentryIds)
+		codecSvc := codecsequence.GetCodecSequenceService(utils.DBE)
+		seqStr := codecSvc.GetReportPistonPumpUnit(this.User.AccCode)
+		fmt.Println(time.Now().Month())
+		svc := limsreportpistonpumpunit.GetLimsReportPistonPumpUnitService(utils.DBE)
+		reportUrl, err = svc.DataToExcelReport(entrustMain, this.User.AccCode+LimsDateEntryName, this.User.AccCode+LimsCreateReportName, this.User.AccCode+LimsReportPistonPumpUnitName, seqStr, docTemplate.FileURL, entrustId, dataentryIds)
+	case limsdoctemplate.DAYT_LIMSREPORTSCREWPUMP_REPORT:
+		codecSvc := codecsequence.GetCodecSequenceService(utils.DBE)
+		seqStr := codecSvc.GetReportScrewPump(this.User.AccCode)
+		svc := limsreportscrewpump.GetLimsReportScrewPumpService(utils.DBE)
+		reportUrl, err = svc.DataToExcelReport(entrustMain, this.User.AccCode+LimsDateEntryName, this.User.AccCode+LimsCreateReportName, this.User.AccCode+LimsReportScrewPumpName, seqStr, docTemplate.FileURL, entrustId, dataentryIds)
 	}
 
 	return reportUrl, UnHGReportUrl, err

+ 13 - 66
src/dashoo.cn/backend/api/controllers/lims/limsreportscrewpump.go

@@ -1,14 +1,15 @@
 package lims
 
 import (
-"dashoo.cn/business2/userRole"
-"dashoo.cn/backend/api/business/baseUser"
-"dashoo.cn/backend/api/business/limsreportscrewpump"
-. "dashoo.cn/backend/api/controllers"
-"dashoo.cn/utils"
-"encoding/json"
-"strings"
-"time"
+	"dashoo.cn/backend/api/business/baseUser"
+	svccustomer "dashoo.cn/backend/api/business/customer"
+	"dashoo.cn/backend/api/business/limsreportscrewpump"
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/business2/userRole"
+	"dashoo.cn/utils"
+	"encoding/json"
+	"strings"
+	"time"
 )
 
 type LimsReportScrewPumpController struct {
@@ -89,252 +90,202 @@ func (this *LimsReportScrewPumpController) GetEntityList() {
 		where = where + " and Id like '%" + Id + "%'"
 	}
 
-
 	if EId != "" {
 		where = where + " and EId like '%" + EId + "%'"
 	}
 
-
 	if TaskBalanceId != "" {
 		where = where + " and TaskBalanceId like '%" + TaskBalanceId + "%'"
 	}
 
-
 	if DataEntryId != "" {
 		where = where + " and DataEntryId like '%" + DataEntryId + "%'"
 	}
 
-
 	if TestDepartId != "" {
 		where = where + " and TestDepartId like '%" + TestDepartId + "%'"
 	}
 
-
 	if PositionCheckId != "" {
 		where = where + " and PositionCheckId like '%" + PositionCheckId + "%'"
 	}
 
-
 	if TestDepart != "" {
 		where = where + " and TestDepart like '%" + TestDepart + "%'"
 	}
 
-
 	if PositionCheck != "" {
 		where = where + " and PositionCheck like '%" + PositionCheck + "%'"
 	}
 
-
 	if CheckDate != "" {
 		where = where + " and CheckDate like '%" + CheckDate + "%'"
 	}
 
-
 	if WellNumber != "" {
 		where = where + " and WellNumber like '%" + WellNumber + "%'"
 	}
 
-
 	if MotorModel != "" {
 		where = where + " and MotorModel like '%" + MotorModel + "%'"
 	}
 
-
 	if MotorRatedPower != "" {
 		where = where + " and MotorRatedPower like '%" + MotorRatedPower + "%'"
 	}
 
-
 	if MotorRatedVoltage != "" {
 		where = where + " and MotorRatedVoltage like '%" + MotorRatedVoltage + "%'"
 	}
 
-
 	if MotorRatedCurrent != "" {
 		where = where + " and MotorRatedCurrent like '%" + MotorRatedCurrent + "%'"
 	}
 
-
 	if MotorRatedSpeed != "" {
 		where = where + " and MotorRatedSpeed like '%" + MotorRatedSpeed + "%'"
 	}
 
-
 	if MotorManufacturer != "" {
 		where = where + " and MotorManufacturer like '%" + MotorManufacturer + "%'"
 	}
 
-
 	if PumpModel != "" {
 		where = where + " and PumpModel like '%" + PumpModel + "%'"
 	}
 
-
 	if PumpDepth != "" {
 		where = where + " and PumpDepth like '%" + PumpDepth + "%'"
 	}
 
-
 	if PumpRatedVoltage != "" {
 		where = where + " and PumpRatedVoltage like '%" + PumpRatedVoltage + "%'"
 	}
 
-
 	if PumpRatedCurrent != "" {
 		where = where + " and PumpRatedCurrent like '%" + PumpRatedCurrent + "%'"
 	}
 
-
 	if PumpRatedSpeed != "" {
 		where = where + " and PumpRatedSpeed like '%" + PumpRatedSpeed + "%'"
 	}
 
-
 	if PumpManufacturer != "" {
 		where = where + " and PumpManufacturer like '%" + PumpManufacturer + "%'"
 	}
 
-
 	if AvgVoltage != "" {
 		where = where + " and AvgVoltage like '%" + AvgVoltage + "%'"
 	}
 
-
 	if AvgCurrent != "" {
 		where = where + " and AvgCurrent like '%" + AvgCurrent + "%'"
 	}
 
-
 	if AvgActivePower != "" {
 		where = where + " and AvgActivePower like '%" + AvgActivePower + "%'"
 	}
 
-
 	if AvgReactivePower != "" {
 		where = where + " and AvgReactivePower like '%" + AvgReactivePower + "%'"
 	}
 
-
 	if AvgPowerFactor != "" {
 		where = where + " and AvgPowerFactor like '%" + AvgPowerFactor + "%'"
 	}
 
-
 	if BackPressure != "" {
 		where = where + " and BackPressure like '%" + BackPressure + "%'"
 	}
 
-
 	if OilPressure != "" {
 		where = where + " and OilPressure like '%" + OilPressure + "%'"
 	}
 
-
 	if CasingPressure != "" {
 		where = where + " and CasingPressure like '%" + CasingPressure + "%'"
 	}
 
-
 	if ProducedFluidVolume != "" {
 		where = where + " and ProducedFluidVolume like '%" + ProducedFluidVolume + "%'"
 	}
 
-
 	if WaterContent != "" {
 		where = where + " and WaterContent like '%" + WaterContent + "%'"
 	}
 
-
 	if CrudeOilDensity != "" {
 		where = where + " and CrudeOilDensity like '%" + CrudeOilDensity + "%'"
 	}
 
-
 	if WorkingFluidLevel != "" {
 		where = where + " and WorkingFluidLevel like '%" + WorkingFluidLevel + "%'"
 	}
 
-
 	if SuctionDepth != "" {
 		where = where + " and SuctionDepth like '%" + SuctionDepth + "%'"
 	}
 
-
 	if StraightOrslope != "" {
 		where = where + " and StraightOrslope like '%" + StraightOrslope + "%'"
 	}
 
-
 	if OilFieldType != "" {
 		where = where + " and OilFieldType like '%" + OilFieldType + "%'"
 	}
 
-
 	if Standard != "" {
 		where = where + " and Standard like '%" + Standard + "%'"
 	}
 
-
 	if MonitoringInstrument != "" {
 		where = where + " and MonitoringInstrument like '%" + MonitoringInstrument + "%'"
 	}
 
-
 	if Temperature != "" {
 		where = where + " and Temperature like '%" + Temperature + "%'"
 	}
 
-
 	if Humidity != "" {
 		where = where + " and Humidity like '%" + Humidity + "%'"
 	}
 
-
 	if BeforeCheck != "" {
 		where = where + " and BeforeCheck like '%" + BeforeCheck + "%'"
 	}
 
-
 	if AfterCheck != "" {
 		where = where + " and AfterCheck like '%" + AfterCheck + "%'"
 	}
 
-
 	if Remark != "" {
 		where = where + " and Remark like '%" + Remark + "%'"
 	}
 
-
 	if CreateUserId != "" {
 		where = where + " and CreateUserId like '%" + CreateUserId + "%'"
 	}
 
-
 	if CreateOn != "" {
 		where = where + " and CreateOn like '%" + CreateOn + "%'"
 	}
 
-
 	if CreateBy != "" {
 		where = where + " and CreateBy like '%" + CreateBy + "%'"
 	}
 
-
 	if ModifiedOn != "" {
 		where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
 	}
 
-
 	if ModifiedUserId != "" {
 		where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
 	}
 
-
 	if ModifiedBy != "" {
 		where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
 	}
 
-
 	if CreateOn != "" {
 		dates := strings.Split(CreateOn, ",")
 		if len(dates) == 2 {
@@ -364,15 +315,15 @@ func (this *LimsReportScrewPumpController) GetDictList() {
 	dictList := make(map[string]interface{})
 	//dictSvc := items.GetItemsService(utils.DBE)
 	userSvc := baseUser.GetBaseUserService(utils.DBE)
-	//customerSvc := svccustomer.GetCustomerService(utils.DBE)
+	customerSvc := svccustomer.GetCustomerService(utils.DBE)
 	//dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
 	var userEntity userRole.Base_User
 	userSvc.GetEntityById(this.User.Id, &userEntity)
 	dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
 
-	//var dictCustomer []svccustomer.Customer
-	//customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
-	//dictList["EntrustCorp"] = &dictCustomer
+	var dictCustomer []svccustomer.Customer
+	customerSvc.GetEntitysByWhere(this.User.AccCode+CustomerName, "", &dictCustomer)
+	dictList["EntrustCorp"] = &dictCustomer
 
 	var datainfo DataInfo
 	datainfo.Items = dictList
@@ -576,8 +527,6 @@ func (this *LimsReportScrewPumpController) UpdateEntity() {
 		"ModifiedUserId",
 
 		"ModifiedBy",
-
-
 	}
 	err := svc.UpdateEntityBytbl(this.User.AccCode+LimsReportScrewPumpName, id, &model, cols)
 	if err == nil {
@@ -625,5 +574,3 @@ func (this *LimsReportScrewPumpController) DeleteEntity() {
 		this.ServeJSON()
 	}
 }
-
-

+ 25 - 1
src/dashoo.cn/frontend_web/src/pages/lims/reportscrewpump/_opera/operation.vue

@@ -32,7 +32,11 @@
         <el-row>
           <el-col :span="6">
             <el-form-item label="被测单位">
-              <el-input v-model.trim="formData.TestDepart" placeholder="请输入" style="width: 100%" :disabled="DataStatus != 0 && DataStatus != 5 && DataStatus != 3" ></el-input>
+              <el-select disabled ref="selectEntrustCorp" v-model="formData.TestDepartId" filterable placeholder="请选择"
+                         style="width: 100%">
+                <el-option v-for="item in EntrustCorpOptions" :key="item.Id" :label="item.CustomerName" :value="item.Id">
+                </el-option>
+              </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -361,6 +365,7 @@
     mapGetters
   } from 'vuex'
   import api from '@/api/lims/limsreportscrewpump'
+  import entrustApi from '@/api/lims/limsentrust'
 
   export default {
     computed: {
@@ -381,6 +386,7 @@
         ischeck: 0,
         DataStatus: '0',
         acceptUsers: [],
+        EntrustCorpOptions: [],
         formData: {
           Id: '',
           EId: '',
@@ -457,9 +463,11 @@
       this.formData.DataEntryId = parseInt(this.DataEntryId)
       this.initData()
       this.getUsersByRole()
+      this.getDictOptions()
     },
     methods: {
       saveEntity () {
+        this.formData.TestDepart = this.$refs.selectEntrustCorp.selectedLabel + ''
         this.$refs['formData'].validate((valid) => {
           if (valid) {
             if (this.formData.Id > 0) {
@@ -509,12 +517,28 @@
           console.error(err)
         })
       },
+      getEntrustInfo (EId) {
+        entrustApi.getEntrustInfo(EId, this.$axios).then(res => {
+          this.formData.TestDepartId = res.data.CustomerId
+        }).catch(err => {
+          // handle error
+          console.error(err)
+        })
+      },
       initData () {
         api.getEntityByDataEntryId(this.formData.DataEntryId, this.$axios).then(res => {
           if (res.data.code === 0) {
             this.formData = res.data.item
           } else {
           }
+          this.getEntrustInfo(this.EId)
+        }).catch(err => {
+          console.error(err)
+        })
+      },
+      getDictOptions () {
+        api.getDictList(this.$axios).then(res => {
+          this.EntrustCorpOptions = res.data.items['EntrustCorp']
         }).catch(err => {
           console.error(err)
         })