package limsmetering import ( "dashoo.cn/backend/api/business/limsdataentry" "dashoo.cn/backend/api/business/limsreportalertor" "dashoo.cn/backend/api/business/limsreportdetelectoxygen" "encoding/json" "fmt" "strconv" "time" . "dashoo.cn/backend/api/controllers" "dashoo.cn/utils" ) type LimsReportDeOxygenController struct { BaseController } type LimsOxygonAllModel struct { BenMainform limsreportalertor.LimsAlertorMainModel CertiArrayList []Certilist AlertValArrayList []AlertValList DeviationArrayList []DeviationList ResponTimeArrayList []ResponTimeList RepeatArrayList []RepeatList ShiftArrayList []ShiftList Id int CerNum string EffectDate time.Time StanDevice string StandVal string StandardUnit string Uncertainty string InstrumentNo string EId int TaskBalanceId int } //@Title 获取实体 //@Description 获取实体 //@Success 200 {object} //@router /get/:id [get] func (this *LimsReportDeOxygenController) GetoxygenEntity() { Id := this.Ctx.Input.Param(":id") sessions := utils.DBE.NewSession() svc := limsreportdetelectoxygen.GetLimsReportOxygenSessionService(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 *LimsReportDeOxygenController) AddOxygenEntity() { sessions := utils.DBE.NewSession() var model LimsOxygonAllModel var err error var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) var dataentrymodel limsdataentry.LimsDateEntry var almodel limsreportalertor.LimsReportAlertor svc := limsreportdetelectoxygen.GetLimsReportOxygenSessionService(sessions) model.Id = model.BenMainform.DataEntryId model.EId = model.BenMainform.EId model.TaskBalanceId = model.BenMainform.TaskBalanceId 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.PositionCheck = model.BenMainform.PositionCheck dataentrymodel.ModifiedOn = time.Now() dataentrymodel.ModifiedBy = this.User.Realname dataentrymodel.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() dataentrycols := []string{ "CustomerName", "StandardDesc", "Instrument1", "PositionCheck", "Temperature", "DetectBasis", "ModifiedOn", "ModifiedBy", "ModifiedUserId", } err = svc.UpdateEntityBywheretbl(this.User.AccCode+LimsDateEntryName, &dataentrymodel, dataentrycols, "Id = "+ utils.ToStr(model.BenMainform.DataEntryId)) 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 = model.BenMainform.DataEntryId almodel.CreateOn = time.Now() almodel.CreateBy = this.User.Realname almodel.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if almodel.MeterRange != "" || almodel.MeasurementRange != "" || almodel.FaceCheck != "" || almodel.FlagCheck != "" || almodel.ElectrifyCheck != "" || almodel.Insulation != "" || almodel.RelativeHumanity != "" || almodel.ManuCompany != "" || almodel.Spec != "" || almodel.FactoryNum != "" || almodel.AudibleAlarm != "" || almodel.AlarmConcentration != "" || almodel.InstrumentLevel != "" || almodel.DielecStrength != "" { _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorName, &almodel) } //证书表 if model.CertiArrayList != nil { for i := 0; i < len(model.CertiArrayList); i++ { 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 = model.BenMainform.DataEntryId cerentity.CreateOn = time.Now() cerentity.CreateBy = this.User.Realname cerentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if cerentity.CerNum != "" || cerentity.StandardUnit != "" || cerentity.StandVal != "" || cerentity.Uncertainty != "" || cerentity.InstrumentNo != "" || cerentity.StanDevice != "" { _, 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 = model.BenMainform.DataEntryId cerentity2.CreateOn = time.Now() cerentity2.CreateBy = this.User.Realname cerentity2.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if cerentity2.CerNum != "" || cerentity2.StandardUnit != "" || cerentity2.StandVal != "" || cerentity2.Uncertainty != "" || cerentity2.InstrumentNo != "" || cerentity2.StanDevice != "" { _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorCertificateName, &cerentity2) } //报警功能表 //if model.AlertValArrayList != nil { // for i := 0; i < len(model.AlertValArrayList); i++ { // 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 = model.BenMainform.DataEntryId // avalentity.CreateOn = time.Now() // avalentity.CreateBy = this.User.Realname // avalentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() // if avalentity.AlertFunction != "" || avalentity.Value1 != 0 || avalentity.Value2 != 0 || avalentity.Value3 != 0 || avalentity.ActionValue != 0 { // _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorValueName, &avalentity) // } // } //} //示值误差表 if model.DeviationArrayList != nil { for i := 0; i < len(model.DeviationArrayList); i++ { 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 = model.BenMainform.DataEntryId devientity.CreateOn = time.Now() devientity.CreateBy = this.User.Realname devientity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if devientity.GasValue != 0 || devientity.Value1 != 0 || devientity.Value2 != 0 || devientity.Value3 != 0 || devientity.AvgValue != 0 || devientity.Deviation != 0 { _, 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 = model.BenMainform.DataEntryId reponseentity.CreateOn = time.Now() reponseentity.CreateBy = this.User.Realname reponseentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if reponseentity.GasValue != 0 || reponseentity.Value1 != 0 || reponseentity.Value2 != 0 || reponseentity.Value3 != 0 || reponseentity.Deviation != 0 { _, 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 = model.BenMainform.DataEntryId repeatentity.CreateOn = time.Now() repeatentity.CreateBy = this.User.Realname repeatentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if repeatentity.GasValue != 0 || repeatentity.Value1 != 0 || repeatentity.Value2 != 0 || repeatentity.Value3 != 0 || repeatentity.Value4 != 0 || repeatentity.Value5 != 0 || repeatentity.Value6 != 0 || repeatentity.AvgValue != 0 || repeatentity.RepeatValue != 0 { _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorRepeatName, &repeatentity) } //漂移表 if model.ShiftArrayList != nil { for i := 0; i < len(model.ShiftArrayList); i++ { 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 = model.BenMainform.DataEntryId shiftentity.CreateOn = time.Now() shiftentity.CreateBy = this.User.Realname shiftentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() if shiftentity.Value0 != 0 || shiftentity.Value1 != 0 || shiftentity.Value2 != 0 || shiftentity.Value3 != 0 || shiftentity.Value4 != 0 || shiftentity.Value5 != 0 || shiftentity.Value6 != 0 || shiftentity.ZeroValue != 0 || shiftentity.ShowValue != 0 { _, err = svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorShiftName, &shiftentity) } } } var errinfo ErrorDataInfo if err == nil { //新增 errinfo.Message = "添加成功!" errinfo.Code = 0 errinfo.Item = almodel.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 *LimsReportDeOxygenController) UpdateoxygenEntity() { 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 LimsOxygonAllModel var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) svc := limsreportdetelectoxygen.GetLimsReportOxygenSessionService(sessions) var dataentrymodel limsdataentry.LimsDateEntry var almodel limsreportalertor.LimsReportAlertor model.Id = model.BenMainform.DataEntryId model.EId = model.BenMainform.EId model.TaskBalanceId = model.BenMainform.TaskBalanceId 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.PositionCheck = model.BenMainform.PositionCheck 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", "PositionCheck", "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) //证书表 if model.CertiArrayList != nil { for i := 0; i < len(model.CertiArrayList); i++ { 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 if model.CertiArrayList[i].Id != 0 { 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) } else { if cerentity.CerNum != "" || cerentity.StandardUnit != "" || cerentity.StandVal != "" || cerentity.Uncertainty != "" || cerentity.InstrumentNo != "" || cerentity.StanDevice != "" { cerentity.EId = model.EId cerentity.TaskBalanceId = model.TaskBalanceId cerentity.DataEntryId = model.BenMainform.DataEntryId 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 if model.Id != 0 { 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) } else { if cerentity2.CerNum != "" || cerentity2.StandardUnit != "" || cerentity2.StandVal != "" || cerentity2.Uncertainty != "" || cerentity2.InstrumentNo != "" || cerentity2.StanDevice != "" { cerentity2.EId = model.EId cerentity2.TaskBalanceId = model.TaskBalanceId cerentity2.DataEntryId = model.BenMainform.DataEntryId 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++ { // 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) //} //示值误差表 if model.DeviationArrayList != nil { for i := 0; i < len(model.DeviationArrayList); i++ { 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 if model.DeviationArrayList[i].Id != 0 { 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) } else { if devientity.GasValue != 0 || devientity.Value1 != 0 || devientity.Value2 != 0 || devientity.Value3 != 0 || devientity.AvgValue != 0 || devientity.DeviationRelative != 0 || devientity.DeviationAbs != 0 { devientity.EId = model.EId devientity.TaskBalanceId = model.TaskBalanceId devientity.DataEntryId = model.BenMainform.DataEntryId 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) } } } } //响应时间表 if model.ResponTimeArrayList != nil { 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 if model.ResponTimeArrayList[0].Id != 0 { 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) } else { if reponseentity.GasValue != 0 || reponseentity.Value1 != 0 || reponseentity.Value2 != 0 || reponseentity.Value3 != 0 || reponseentity.Deviation != 0 { reponseentity.EId = model.EId reponseentity.TaskBalanceId = model.TaskBalanceId reponseentity.DataEntryId = model.BenMainform.DataEntryId 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) } } } //重复性表 if model.RepeatArrayList != nil { 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 if model.RepeatArrayList[0].Id != 0 { 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) } else { if repeatentity.GasValue != 0 || repeatentity.Value1 != 0 || repeatentity.Value2 != 0 || repeatentity.Value3 != 0 || repeatentity.Value4 != 0 || repeatentity.Value5 != 0 || repeatentity.Value6 != 0 || repeatentity.AvgValue != 0 || repeatentity.RepeatValue != 0 { repeatentity.EId = model.EId repeatentity.TaskBalanceId = model.TaskBalanceId repeatentity.DataEntryId = model.BenMainform.DataEntryId 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) } } } //漂移表 if model.ShiftArrayList != nil { for i := 0; i < len(model.ShiftArrayList); i++ { 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 if model.ShiftArrayList[i].Id != 0 { 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) } else { if shiftentity.Value0 != 0 || shiftentity.Value1 != 0 || shiftentity.Value2 != 0 || shiftentity.Value3 != 0 || shiftentity.Value4 != 0 || shiftentity.Value5 != 0 || shiftentity.Value6 != 0 || shiftentity.ZeroValue != 0 || shiftentity.ShowValue != 0 { shiftentity.EId = model.EId shiftentity.TaskBalanceId = model.TaskBalanceId shiftentity.DataEntryId = model.BenMainform.DataEntryId 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) } } } } 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() } }