|
|
@@ -0,0 +1,610 @@
|
|
|
+package limsmetering
|
|
|
+
|
|
|
+import (
|
|
|
+ "dashoo.cn/backend/api/business/limsdataentry"
|
|
|
+ "dashoo.cn/backend/api/business/limsreportalertor"
|
|
|
+ "dashoo.cn/backend/api/business/limsreportben"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "strconv"
|
|
|
+
|
|
|
+ "time"
|
|
|
+
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+)
|
|
|
+
|
|
|
+type LimsReportBenController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+type LimsBenAllModel struct {
|
|
|
+ BenMainform limsreportalertor.LimsAlertorMainModel
|
|
|
+ CertiArrayList []Certilist
|
|
|
+ AlertValArrayList []AlertValList
|
|
|
+ DeviationArrayList []DeviationList
|
|
|
+ ResponTimeArrayList []ResponTimeList
|
|
|
+ RepeatArrayList []RepeatList
|
|
|
+ ShiftArrayList []ShiftList
|
|
|
+ CerNum string
|
|
|
+ EffectDate time.Time
|
|
|
+ StanDevice string
|
|
|
+ StandVal string
|
|
|
+ StandardUnit string
|
|
|
+ Uncertainty string
|
|
|
+ InstrumentNo string
|
|
|
+ EId int
|
|
|
+ TaskBalanceId int
|
|
|
+}
|
|
|
+type Certilist struct {
|
|
|
+ CerNum string
|
|
|
+ EffectDate time.Time
|
|
|
+ StandVal string
|
|
|
+ StandardUnit string
|
|
|
+ Uncertainty string
|
|
|
+ StanDevice string
|
|
|
+ InstrumentNo string
|
|
|
+}
|
|
|
+type AlertValList struct {
|
|
|
+ AlertFunc []string
|
|
|
+ AlertFunction string
|
|
|
+ Value1 float64
|
|
|
+ Value2 float64
|
|
|
+ Value3 float64
|
|
|
+ ActionValue float64
|
|
|
+ SureValue float64
|
|
|
+ MaxValue float64
|
|
|
+ AllowValue float64
|
|
|
+}
|
|
|
+type DeviationList struct {
|
|
|
+ GasValue float64
|
|
|
+ Value1 float64
|
|
|
+ Value2 float64
|
|
|
+ Value3 float64
|
|
|
+ AvgValue string
|
|
|
+ Deviation float64
|
|
|
+ DeviationAbs float64
|
|
|
+ DeviationRelative float64
|
|
|
+}
|
|
|
+type ResponTimeList struct {
|
|
|
+ GasValue float64
|
|
|
+ Value1 float64
|
|
|
+ Value2 float64
|
|
|
+ Value3 float64
|
|
|
+ Deviation float64
|
|
|
+}
|
|
|
+type RepeatList struct {
|
|
|
+ GasValue float64
|
|
|
+ Value1 float64
|
|
|
+ Value2 float64
|
|
|
+ Value3 float64
|
|
|
+ Value4 float64
|
|
|
+ Value5 float64
|
|
|
+ Value6 float64
|
|
|
+ AvgValue string
|
|
|
+ RepeatValue float64
|
|
|
+}
|
|
|
+type ShiftList struct {
|
|
|
+ ValueType string
|
|
|
+ Value0 float64
|
|
|
+ Value1 float64
|
|
|
+ Value2 float64
|
|
|
+ Value3 float64
|
|
|
+ Value4 float64
|
|
|
+ Value5 float64
|
|
|
+ Value6 float64
|
|
|
+ ZeroValue float64
|
|
|
+ ShowValue float64
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//@Title 获取实体
|
|
|
+//@Description 获取实体
|
|
|
+//@Success 200 {object}
|
|
|
+//@router /get/:id [get]
|
|
|
+func (this *LimsReportBenController) GetEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+ sessions := utils.DBE.NewSession()
|
|
|
+ svc := limsreportben.GetLimsReportBenSessionService(sessions)
|
|
|
+ var mainmodel limsreportalertor.LimsAlertorMainModel
|
|
|
+ var alertvaluelist []limsreportalertor.LimsReportAlertorValue
|
|
|
+ var cervaluelist []limsreportalertor.LimsReportAlertorCertificate
|
|
|
+ var alertdeviationlist []limsreportalertor.LimsReportAlertorDeviation
|
|
|
+ var alertresponsetimelist []limsreportalertor.LimsReportAlertorResponseTime
|
|
|
+ var alertrepeatlist []limsreportalertor.LimsReportAlertorRepeat
|
|
|
+ var alertshiftlist []limsreportalertor.LimsReportAlertorShift
|
|
|
+ where := "DataEntryId = "+Id
|
|
|
+ mainmodel = svc.GetEntityByOrderbyWhereMain(this.User.AccCode+LimsDateEntryName, this.User.AccCode+LimsReportAlertorName, "a.Id", Id)
|
|
|
+ fmt.Println(mainmodel)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorCertificateName, where, "Id", &cervaluelist)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorValueName, where, "Id", &alertvaluelist)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorDeviationName, where, "Id", &alertdeviationlist)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorResponseTimeName, where, "Id", &alertresponsetimelist)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorRepeatName, where, "Id", &alertrepeatlist)
|
|
|
+ svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsReportAlertorShiftName, where, "Id", &alertshiftlist)
|
|
|
+ var responinfo ALterDataInfo
|
|
|
+ responinfo.MainItem = mainmodel
|
|
|
+ responinfo.AlvalItem = alertvaluelist
|
|
|
+ responinfo.CerItem = cervaluelist
|
|
|
+ responinfo.DeviItem = alertdeviationlist
|
|
|
+ responinfo.RepeatItem = alertrepeatlist
|
|
|
+ responinfo.ResponItem = alertresponsetimelist
|
|
|
+ responinfo.ShiftItem = alertshiftlist
|
|
|
+ this.Data["json"] = &responinfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /add/ [post]
|
|
|
+func (this *LimsReportBenController) AddEntity() {
|
|
|
+ sessions := utils.DBE.NewSession()
|
|
|
+ var model LimsBenAllModel
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ var dataentrymodel limsdataentry.LimsDateEntry
|
|
|
+ var almodel limsreportalertor.LimsReportAlertor
|
|
|
+ svc := limsreportben.GetLimsReportBenSessionService(sessions)
|
|
|
+ dataentrymodel.Instrument1 = model.BenMainform.Instrument1
|
|
|
+ dataentrymodel.DetectBasis = model.BenMainform.DetectBasis
|
|
|
+ dataentrymodel.CustomerName = model.BenMainform.CustomerName
|
|
|
+ dataentrymodel.Temperature = model.BenMainform.Temperature
|
|
|
+ dataentrymodel.StandardDesc = model.BenMainform.StandardDesc
|
|
|
+ dataentrymodel.CreateOn = time.Now()
|
|
|
+ dataentrymodel.CreateBy = this.User.Realname
|
|
|
+ dataentrymodel.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err := svc.InsertEntityBytbl(this.User.AccCode+LimsDateEntryName, &dataentrymodel)
|
|
|
+ almodel.MeterRange = model.BenMainform.MeterRange
|
|
|
+ almodel.MeasurementRange = model.BenMainform.MeasurementRange
|
|
|
+ almodel.FaceCheck = model.BenMainform.FaceCheck
|
|
|
+ almodel.FlagCheck = model.BenMainform.FlagCheck
|
|
|
+ almodel.ElectrifyCheck = model.BenMainform.ElectrifyCheck
|
|
|
+ almodel.Insulation = model.BenMainform.Insulation
|
|
|
+ almodel.RelativeHumanity = model.BenMainform.RelativeHumanity
|
|
|
+ almodel.ManuCompany = model.BenMainform.ManuCompany
|
|
|
+ almodel.Spec = model.BenMainform.Spec
|
|
|
+ almodel.FactoryNum = model.BenMainform.FactoryNum
|
|
|
+ almodel.AudibleAlarm = model.BenMainform.AudibleAlarm
|
|
|
+ almodel.AlarmConcentration = model.BenMainform.AlarmConcentration
|
|
|
+ almodel.InstrumentLevel = model.BenMainform.InstrumentLevel
|
|
|
+ almodel.DielecStrength = model.BenMainform.DielecStrength
|
|
|
+ almodel.EId = model.EId
|
|
|
+ almodel.TaskBalanceId = model.TaskBalanceId
|
|
|
+ almodel.DataEntryId = dataentrymodel.Id
|
|
|
+ almodel.CreateOn = time.Now()
|
|
|
+ almodel.CreateBy = this.User.Realname
|
|
|
+ almodel.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorName, &almodel)
|
|
|
+ //证书表
|
|
|
+ for i := 0; i < len(model.CertiArrayList); i++ {
|
|
|
+ if model.CertiArrayList[i].CerNum != "" {
|
|
|
+ var cerentity limsreportalertor.LimsReportAlertorCertificate
|
|
|
+ cerentity.CerNum = model.CertiArrayList[i].CerNum
|
|
|
+ cerentity.StandardUnit = model.CertiArrayList[i].StandardUnit
|
|
|
+ cerentity.StandVal = model.CertiArrayList[i].StandVal
|
|
|
+ cerentity.Uncertainty = model.CertiArrayList[i].Uncertainty
|
|
|
+ cerentity.EffectDate = model.CertiArrayList[i].EffectDate
|
|
|
+ cerentity.InstrumentNo = model.CertiArrayList[i].InstrumentNo
|
|
|
+ cerentity.StanDevice = model.CertiArrayList[i].StanDevice
|
|
|
+ cerentity.EId = model.EId
|
|
|
+ cerentity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ cerentity.DataEntryId = dataentrymodel.Id
|
|
|
+ cerentity.CreateOn = time.Now()
|
|
|
+ cerentity.CreateBy = this.User.Realname
|
|
|
+ cerentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorCertificateName, &cerentity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var cerentity2 limsreportalertor.LimsReportAlertorCertificate
|
|
|
+ cerentity2.CerNum = model.CerNum
|
|
|
+ cerentity2.StandardUnit = model.StandardUnit
|
|
|
+ cerentity2.StandVal = model.StandVal
|
|
|
+ cerentity2.Uncertainty = model.Uncertainty
|
|
|
+ cerentity2.EffectDate = model.EffectDate
|
|
|
+ cerentity2.InstrumentNo = model.InstrumentNo
|
|
|
+ cerentity2.StanDevice = model.StanDevice
|
|
|
+ cerentity2.EId = model.EId
|
|
|
+ cerentity2.TaskBalanceId = model.TaskBalanceId
|
|
|
+ cerentity2.DataEntryId = dataentrymodel.Id
|
|
|
+ cerentity2.CreateOn = time.Now()
|
|
|
+ cerentity2.CreateBy = this.User.Realname
|
|
|
+ cerentity2.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorCertificateName, &cerentity2)
|
|
|
+
|
|
|
+ //报警功能表
|
|
|
+ for i := 0; i < len(model.AlertValArrayList); i++ {
|
|
|
+ if model.AlertValArrayList[i].AlertFunction != "" {
|
|
|
+ var avalentity limsreportalertor.LimsReportAlertorValue
|
|
|
+ avalentity.AlertFunction = model.AlertValArrayList[i].AlertFunction
|
|
|
+ avalentity.Value1 = model.AlertValArrayList[i].Value1
|
|
|
+ avalentity.Value2 = model.AlertValArrayList[i].Value2
|
|
|
+ avalentity.Value3 = model.AlertValArrayList[i].Value3
|
|
|
+ avalentity.ActionValue = model.AlertValArrayList[i].ActionValue
|
|
|
+ avalentity.EId = model.EId
|
|
|
+ avalentity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ avalentity.DataEntryId = dataentrymodel.Id
|
|
|
+ avalentity.CreateOn = time.Now()
|
|
|
+ avalentity.CreateBy = this.User.Realname
|
|
|
+ avalentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorValueName, &avalentity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //示值误差表
|
|
|
+ for i := 0; i < len(model.DeviationArrayList); i++ {
|
|
|
+ if model.DeviationArrayList[i].GasValue != '0' {
|
|
|
+ var devientity limsreportalertor.LimsReportAlertorDeviation
|
|
|
+ devientity.GasValue = model.DeviationArrayList[i].GasValue
|
|
|
+ devientity.Value1 = model.DeviationArrayList[i].Value1
|
|
|
+ devientity.Value2 = model.DeviationArrayList[i].Value2
|
|
|
+ devientity.Value3 = model.DeviationArrayList[i].Value3
|
|
|
+ devientity.AvgValue, _ = strconv.ParseFloat(model.DeviationArrayList[i].AvgValue,64)
|
|
|
+ devientity.Deviation = model.DeviationArrayList[i].Deviation
|
|
|
+ devientity.EId = model.EId
|
|
|
+ devientity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ devientity.DataEntryId = dataentrymodel.Id
|
|
|
+ devientity.CreateOn = time.Now()
|
|
|
+ devientity.CreateBy = this.User.Realname
|
|
|
+ devientity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorDeviationName, &devientity)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //响应时间表
|
|
|
+ var reponseentity limsreportalertor.LimsReportAlertorResponseTime
|
|
|
+ reponseentity.GasValue = model.ResponTimeArrayList[0].GasValue
|
|
|
+ reponseentity.Value1 = model.ResponTimeArrayList[0].Value1
|
|
|
+ reponseentity.Value2 = model.ResponTimeArrayList[0].Value2
|
|
|
+ reponseentity.Value3 = model.ResponTimeArrayList[0].Value3
|
|
|
+ reponseentity.Deviation = model.ResponTimeArrayList[0].Deviation
|
|
|
+ reponseentity.EId = model.EId
|
|
|
+ reponseentity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ reponseentity.DataEntryId = dataentrymodel.Id
|
|
|
+ reponseentity.CreateOn = time.Now()
|
|
|
+ reponseentity.CreateBy = this.User.Realname
|
|
|
+ reponseentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorResponseTimeName, &reponseentity)
|
|
|
+
|
|
|
+ //重复性表
|
|
|
+ var repeatentity limsreportalertor.LimsReportAlertorRepeat
|
|
|
+ repeatentity.GasValue = model.RepeatArrayList[0].GasValue
|
|
|
+ repeatentity.Value1 = model.RepeatArrayList[0].Value1
|
|
|
+ repeatentity.Value2 = model.RepeatArrayList[0].Value2
|
|
|
+ repeatentity.Value3 = model.RepeatArrayList[0].Value3
|
|
|
+ repeatentity.Value4 = model.RepeatArrayList[0].Value4
|
|
|
+ repeatentity.Value5 = model.RepeatArrayList[0].Value5
|
|
|
+ repeatentity.Value6 = model.RepeatArrayList[0].Value6
|
|
|
+ repeatentity.AvgValue, _ = strconv.ParseFloat(model.RepeatArrayList[0].AvgValue,64)
|
|
|
+ repeatentity.RepeatValue = model.RepeatArrayList[0].RepeatValue
|
|
|
+ repeatentity.EId = model.EId
|
|
|
+ repeatentity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ repeatentity.DataEntryId = dataentrymodel.Id
|
|
|
+ repeatentity.CreateOn = time.Now()
|
|
|
+ repeatentity.CreateBy = this.User.Realname
|
|
|
+ repeatentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorRepeatName, &repeatentity)
|
|
|
+
|
|
|
+ //漂移表
|
|
|
+ for i := 0; i < len(model.ShiftArrayList); i++ {
|
|
|
+ if model.ShiftArrayList[i].Value0 != '0' {
|
|
|
+ var shiftentity limsreportalertor.LimsReportAlertorShift
|
|
|
+ shiftentity.ValueType = model.ShiftArrayList[i].ValueType
|
|
|
+ shiftentity.Value0 = model.ShiftArrayList[i].Value0
|
|
|
+ shiftentity.Value1 = model.ShiftArrayList[i].Value1
|
|
|
+ shiftentity.Value2 = model.ShiftArrayList[i].Value2
|
|
|
+ shiftentity.Value3 = model.ShiftArrayList[i].Value3
|
|
|
+ shiftentity.Value4 = model.ShiftArrayList[i].Value4
|
|
|
+ shiftentity.Value5 = model.ShiftArrayList[i].Value5
|
|
|
+ shiftentity.Value6 = model.ShiftArrayList[i].Value6
|
|
|
+ shiftentity.ZeroValue = model.ShiftArrayList[i].ZeroValue
|
|
|
+ shiftentity.ShowValue = model.ShiftArrayList[i].ShowValue
|
|
|
+ shiftentity.EId = model.EId
|
|
|
+ shiftentity.TaskBalanceId = model.TaskBalanceId
|
|
|
+ shiftentity.DataEntryId = dataentrymodel.Id
|
|
|
+ shiftentity.CreateOn = time.Now()
|
|
|
+ shiftentity.CreateBy = this.User.Realname
|
|
|
+ shiftentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorShiftName, &shiftentity)
|
|
|
+
|
|
|
+ }
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if err == nil {
|
|
|
+ //新增
|
|
|
+ errinfo.Message = "添加成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Item = dataentrymodel.Id
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 修改数据
|
|
|
+// @Description 修改数据
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /update/:id [post]
|
|
|
+func (this *LimsReportBenController) UpdateEntity() {
|
|
|
+ dataentryid := this.Ctx.Input.Param(":id")
|
|
|
+ var errinfo ErrorInfo
|
|
|
+ if dataentryid == "" {
|
|
|
+ errinfo.Message = "操作失败!请求信息不完整"
|
|
|
+ errinfo.Code = -2
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sessions := utils.DBE.NewSession()
|
|
|
+ var model LimsBenAllModel
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ svc := limsreportben.GetLimsReportBenSessionService(sessions)
|
|
|
+ var dataentrymodel limsdataentry.LimsDateEntry
|
|
|
+ var almodel limsreportalertor.LimsReportAlertor
|
|
|
+ dataentrymodel.Instrument1 = model.BenMainform.Instrument1
|
|
|
+ dataentrymodel.DetectBasis = model.BenMainform.DetectBasis
|
|
|
+ dataentrymodel.CustomerName = model.BenMainform.CustomerName
|
|
|
+ dataentrymodel.Temperature = model.BenMainform.Temperature
|
|
|
+ dataentrymodel.StandardDesc = model.BenMainform.StandardDesc
|
|
|
+ dataentrymodel.ModifiedOn = time.Now()
|
|
|
+ dataentrymodel.ModifiedBy = this.User.Realname
|
|
|
+ dataentrymodel.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ almodel.MeterRange = model.BenMainform.MeterRange
|
|
|
+ almodel.MeasurementRange = model.BenMainform.MeasurementRange
|
|
|
+ almodel.FaceCheck = model.BenMainform.FaceCheck
|
|
|
+ almodel.FlagCheck = model.BenMainform.FlagCheck
|
|
|
+ almodel.ElectrifyCheck = model.BenMainform.ElectrifyCheck
|
|
|
+ almodel.Insulation = model.BenMainform.Insulation
|
|
|
+ almodel.RelativeHumanity = model.BenMainform.RelativeHumanity
|
|
|
+ almodel.ManuCompany = model.BenMainform.ManuCompany
|
|
|
+ almodel.Spec = model.BenMainform.Spec
|
|
|
+ almodel.FactoryNum = model.BenMainform.FactoryNum
|
|
|
+ almodel.AudibleAlarm = model.BenMainform.AudibleAlarm
|
|
|
+ almodel.AlarmConcentration = model.BenMainform.AlarmConcentration
|
|
|
+ almodel.InstrumentLevel = model.BenMainform.InstrumentLevel
|
|
|
+ almodel.DielecStrength = model.BenMainform.DielecStrength
|
|
|
+ almodel.ModifiedOn = time.Now()
|
|
|
+ almodel.ModifiedBy = this.User.Realname
|
|
|
+ almodel.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ dataentrycols := []string{
|
|
|
+ "CustomerName",
|
|
|
+ "StandardDesc",
|
|
|
+ "Instrument1",
|
|
|
+ "Temperature",
|
|
|
+ "DetectBasis",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err := svc.UpdateEntityBytbl(this.User.AccCode+LimsDateEntryName, dataentryid, &dataentrymodel, dataentrycols)
|
|
|
+ alcols := []string{
|
|
|
+ "MeterRange",
|
|
|
+ "MeasurementRange",
|
|
|
+ "FaceCheck",
|
|
|
+ "FlagCheck",
|
|
|
+ "ElectrifyCheck",
|
|
|
+ "Insulation",
|
|
|
+ "RelativeHumanity",
|
|
|
+ "ManuCompany",
|
|
|
+ "Spec",
|
|
|
+ "FactoryNum",
|
|
|
+ "AudibleAlarm",
|
|
|
+ "AlarmConcentration",
|
|
|
+ "InstrumentLevel",
|
|
|
+ "DielecStrength",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ alwhere := "DataEntryId = "+dataentryid
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorName, &almodel, alcols, alwhere)
|
|
|
+ //证书表
|
|
|
+ for i := 0; i < len(model.CertiArrayList); i++ {
|
|
|
+ if model.CertiArrayList[i].CerNum != "" {
|
|
|
+ var cerentity limsreportalertor.LimsReportAlertorCertificate
|
|
|
+ cerentity.CerNum = model.CertiArrayList[i].CerNum
|
|
|
+ cerentity.StandardUnit = model.CertiArrayList[i].StandardUnit
|
|
|
+ cerentity.StandVal = model.CertiArrayList[i].StandVal
|
|
|
+ cerentity.Uncertainty = model.CertiArrayList[i].Uncertainty
|
|
|
+ cerentity.EffectDate = model.CertiArrayList[i].EffectDate
|
|
|
+ cerentity.InstrumentNo = model.CertiArrayList[i].InstrumentNo
|
|
|
+ cerentity.StanDevice = model.CertiArrayList[i].StanDevice
|
|
|
+ cerentity.ModifiedOn = time.Now()
|
|
|
+ cerentity.ModifiedBy = this.User.Realname
|
|
|
+ cerentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ cercols := []string{
|
|
|
+ "CerNum",
|
|
|
+ "StandardUnit",
|
|
|
+ "StandVal",
|
|
|
+ "Uncertainty",
|
|
|
+ "EffectDate",
|
|
|
+ "InstrumentNo",
|
|
|
+ "StanDevice",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorCertificateName, &cerentity, cercols, alwhere)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var cerentity2 limsreportalertor.LimsReportAlertorCertificate
|
|
|
+ cerentity2.CerNum = model.CerNum
|
|
|
+ cerentity2.StandardUnit = model.StandardUnit
|
|
|
+ cerentity2.StandVal = model.StandVal
|
|
|
+ cerentity2.Uncertainty = model.Uncertainty
|
|
|
+ cerentity2.EffectDate = model.EffectDate
|
|
|
+ cerentity2.InstrumentNo = model.InstrumentNo
|
|
|
+ cerentity2.StanDevice = model.StanDevice
|
|
|
+ cerentity2.ModifiedOn = time.Now()
|
|
|
+ cerentity2.ModifiedBy = this.User.Realname
|
|
|
+ cerentity2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ cer2cols := []string{
|
|
|
+ "CerNum",
|
|
|
+ "StandardUnit",
|
|
|
+ "StandVal",
|
|
|
+ "Uncertainty",
|
|
|
+ "EffectDate",
|
|
|
+ "InstrumentNo",
|
|
|
+ "StanDevice",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorCertificateName, &cerentity2, cer2cols, alwhere)
|
|
|
+
|
|
|
+ //报警功能表
|
|
|
+ for i := 0; i < len(model.AlertValArrayList); i++ {
|
|
|
+ if model.AlertValArrayList[i].AlertFunction != "" {
|
|
|
+ var avalentity limsreportalertor.LimsReportAlertorValue
|
|
|
+ avalentity.AlertFunction = model.AlertValArrayList[i].AlertFunction
|
|
|
+ avalentity.Value1 = model.AlertValArrayList[i].Value1
|
|
|
+ avalentity.Value2 = model.AlertValArrayList[i].Value2
|
|
|
+ avalentity.Value3 = model.AlertValArrayList[i].Value3
|
|
|
+ avalentity.ActionValue = model.AlertValArrayList[i].ActionValue
|
|
|
+ avalentity.ModifiedOn = time.Now()
|
|
|
+ avalentity.ModifiedBy = this.User.Realname
|
|
|
+ avalentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ alvalcols := []string{
|
|
|
+ "AlertFunction",
|
|
|
+ "Value1",
|
|
|
+ "Value2",
|
|
|
+ "Value3",
|
|
|
+ "ActionValue",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorValueName, &avalentity, alvalcols, alwhere)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //示值误差表
|
|
|
+ for i := 0; i < len(model.DeviationArrayList); i++ {
|
|
|
+ if model.DeviationArrayList[i].GasValue != '0' {
|
|
|
+ var devientity limsreportalertor.LimsReportAlertorDeviation
|
|
|
+ devientity.GasValue = model.DeviationArrayList[i].GasValue
|
|
|
+ devientity.Value1 = model.DeviationArrayList[i].Value1
|
|
|
+ devientity.Value2 = model.DeviationArrayList[i].Value2
|
|
|
+ devientity.Value3 = model.DeviationArrayList[i].Value3
|
|
|
+ devientity.AvgValue, _ = strconv.ParseFloat(model.DeviationArrayList[i].AvgValue,64)
|
|
|
+ devientity.Deviation = model.DeviationArrayList[i].Deviation
|
|
|
+ devientity.ModifiedOn = time.Now()
|
|
|
+ devientity.ModifiedBy = this.User.Realname
|
|
|
+ devientity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ devicols := []string{
|
|
|
+ "GasValue",
|
|
|
+ "Value1",
|
|
|
+ "Value2",
|
|
|
+ "Value3",
|
|
|
+ "AvgValue",
|
|
|
+ "Deviation",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorDeviationName, &devientity, devicols, alwhere)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //响应时间表
|
|
|
+ var reponseentity limsreportalertor.LimsReportAlertorResponseTime
|
|
|
+ reponseentity.GasValue = model.ResponTimeArrayList[0].GasValue
|
|
|
+ reponseentity.Value1 = model.ResponTimeArrayList[0].Value1
|
|
|
+ reponseentity.Value2 = model.ResponTimeArrayList[0].Value2
|
|
|
+ reponseentity.Value3 = model.ResponTimeArrayList[0].Value3
|
|
|
+ reponseentity.Deviation = model.ResponTimeArrayList[0].Deviation
|
|
|
+ reponseentity.ModifiedOn = time.Now()
|
|
|
+ reponseentity.ModifiedBy = this.User.Realname
|
|
|
+ reponseentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ responcols := []string{
|
|
|
+ "GasValue",
|
|
|
+ "Value1",
|
|
|
+ "Value2",
|
|
|
+ "Value3",
|
|
|
+ "Deviation",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorResponseTimeName, &reponseentity, responcols, alwhere)
|
|
|
+
|
|
|
+ //重复性表
|
|
|
+ var repeatentity limsreportalertor.LimsReportAlertorRepeat
|
|
|
+ repeatentity.GasValue = model.RepeatArrayList[0].GasValue
|
|
|
+ repeatentity.Value1 = model.RepeatArrayList[0].Value1
|
|
|
+ repeatentity.Value2 = model.RepeatArrayList[0].Value2
|
|
|
+ repeatentity.Value3 = model.RepeatArrayList[0].Value3
|
|
|
+ repeatentity.Value4 = model.RepeatArrayList[0].Value4
|
|
|
+ repeatentity.Value5 = model.RepeatArrayList[0].Value5
|
|
|
+ repeatentity.Value6 = model.RepeatArrayList[0].Value6
|
|
|
+ repeatentity.AvgValue, _ = strconv.ParseFloat(model.RepeatArrayList[0].AvgValue,64)
|
|
|
+ repeatentity.RepeatValue = model.RepeatArrayList[0].RepeatValue
|
|
|
+ repeatentity.ModifiedOn = time.Now()
|
|
|
+ repeatentity.ModifiedBy = this.User.Realname
|
|
|
+ repeatentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ repeacols := []string{
|
|
|
+ "GasValue",
|
|
|
+ "Value1",
|
|
|
+ "Value2",
|
|
|
+ "Value3",
|
|
|
+ "Value4",
|
|
|
+ "Value5",
|
|
|
+ "Value6",
|
|
|
+ "AvgValue",
|
|
|
+ "RepeatValue",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorRepeatName, &repeatentity, repeacols, alwhere)
|
|
|
+
|
|
|
+ //漂移表
|
|
|
+ for i := 0; i < len(model.ShiftArrayList); i++ {
|
|
|
+ if model.ShiftArrayList[i].Value0 != '0' {
|
|
|
+ var shiftentity limsreportalertor.LimsReportAlertorShift
|
|
|
+ shiftentity.ValueType = model.ShiftArrayList[i].ValueType
|
|
|
+ shiftentity.Value1 = model.ShiftArrayList[i].Value1
|
|
|
+ shiftentity.Value2 = model.ShiftArrayList[i].Value2
|
|
|
+ shiftentity.Value3 = model.ShiftArrayList[i].Value3
|
|
|
+ shiftentity.Value4 = model.ShiftArrayList[i].Value4
|
|
|
+ shiftentity.Value5 = model.ShiftArrayList[i].Value5
|
|
|
+ shiftentity.Value6 = model.ShiftArrayList[i].Value6
|
|
|
+ shiftentity.ZeroValue = model.ShiftArrayList[i].ZeroValue
|
|
|
+ shiftentity.ShowValue = model.ShiftArrayList[i].ShowValue
|
|
|
+ shiftentity.ModifiedOn = time.Now()
|
|
|
+ shiftentity.ModifiedBy = this.User.Realname
|
|
|
+ shiftentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ shiftcols := []string{
|
|
|
+ "ValueType",
|
|
|
+ "Value1",
|
|
|
+ "Value2",
|
|
|
+ "Value3",
|
|
|
+ "Value4",
|
|
|
+ "Value5",
|
|
|
+ "Value6",
|
|
|
+ "ZeroValue",
|
|
|
+ "ShowValue",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedBy",
|
|
|
+ "ModifiedUserId",
|
|
|
+ }
|
|
|
+ err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsReportAlertorShiftName, &shiftentity, shiftcols, alwhere)
|
|
|
+ }
|
|
|
+ if err == nil {
|
|
|
+ errinfo.Message = "修改成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|