|
|
@@ -0,0 +1,350 @@
|
|
|
+package lims
|
|
|
+
|
|
|
+import (
|
|
|
+ "dashoo.cn/business/userRole"
|
|
|
+ "dashoo.cn/backend/api/business/baseUser"
|
|
|
+ "dashoo.cn/backend/api/business/limsreportalertor"
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+ "encoding/json"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type LimsReportAlertorController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object} []limsreportalertor.LimsReportAlertor
|
|
|
+// @router /list [get]
|
|
|
+func (this *LimsReportAlertorController) GetEntityList() {
|
|
|
+
|
|
|
+ //获取分页信息
|
|
|
+ page := this.GetPageInfoForm()
|
|
|
+ where := " 1=1 "
|
|
|
+ orderby := "Id"
|
|
|
+ asc := false
|
|
|
+ Order := this.GetString("Order")
|
|
|
+ Prop := this.GetString("Prop")
|
|
|
+ if Order != "" && Prop != "" {
|
|
|
+ orderby = Prop
|
|
|
+ if Order == "asc" {
|
|
|
+ asc = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Id := this.GetString("Id")
|
|
|
+ EId := this.GetString("EId")
|
|
|
+ TaskBalanceId := this.GetString("TaskBalanceId")
|
|
|
+ DataEntryId := this.GetString("DataEntryId")
|
|
|
+ MeterRange := this.GetString("MeterRange")
|
|
|
+ MeasurementRange := this.GetString("MeasurementRange")
|
|
|
+ DetectBasis := this.GetString("DetectBasis")
|
|
|
+ FaceCheck := this.GetString("FaceCheck")
|
|
|
+ FlagCheck := this.GetString("FlagCheck")
|
|
|
+ ElectrifyCheck := this.GetString("ElectrifyCheck")
|
|
|
+ Insulation := this.GetString("Insulation")
|
|
|
+ Remark := this.GetString("Remark")
|
|
|
+ CreateUserId := this.GetString("CreateUserId")
|
|
|
+ CreateOn := this.GetString("CreateOn")
|
|
|
+ CreateBy := this.GetString("CreateBy")
|
|
|
+ ModifiedOn := this.GetString("ModifiedOn")
|
|
|
+ ModifiedUserId := this.GetString("ModifiedUserId")
|
|
|
+ ModifiedBy := this.GetString("ModifiedBy")
|
|
|
+
|
|
|
+ if Id != "" {
|
|
|
+ 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 MeterRange != "" {
|
|
|
+ where = where + " and MeterRange like '%" + MeterRange + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if MeasurementRange != "" {
|
|
|
+ where = where + " and MeasurementRange like '%" + MeasurementRange + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if DetectBasis != "" {
|
|
|
+ where = where + " and DetectBasis like '%" + DetectBasis + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if FaceCheck != "" {
|
|
|
+ where = where + " and FaceCheck like '%" + FaceCheck + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if FlagCheck != "" {
|
|
|
+ where = where + " and FlagCheck like '%" + FlagCheck + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ElectrifyCheck != "" {
|
|
|
+ where = where + " and ElectrifyCheck like '%" + ElectrifyCheck + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Insulation != "" {
|
|
|
+ where = where + " and Insulation like '%" + Insulation + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 {
|
|
|
+ minDate := dates[0]
|
|
|
+ maxDate := dates[1]
|
|
|
+ where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ svc := limsreportalertor.GetLimsReportAlertorService(utils.DBE)
|
|
|
+ var list []limsreportalertor.LimsReportAlertor
|
|
|
+ total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
+ var datainfo DataInfo
|
|
|
+ datainfo.Items = list
|
|
|
+ datainfo.CurrentItemCount = total
|
|
|
+ datainfo.PageIndex = page.CurrentPage
|
|
|
+ datainfo.ItemsPerPage = page.Size
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取字典列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object} map[string]interface{}
|
|
|
+// @router /dictlist [get]
|
|
|
+func (this *LimsReportAlertorController) GetDictList() {
|
|
|
+ dictList := make(map[string]interface{})
|
|
|
+ //dictSvc := items.GetItemsService(utils.DBE)
|
|
|
+ userSvc := baseUser.GetBaseUserService(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 datainfo DataInfo
|
|
|
+ datainfo.Items = dictList
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取实体
|
|
|
+// @Description 获取实体
|
|
|
+// @Success 200 {object} limsreportalertor.LimsReportAlertor
|
|
|
+// @router /get/:id [get]
|
|
|
+func (this *LimsReportAlertorController) GetEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+
|
|
|
+ var model limsreportalertor.LimsReportAlertor
|
|
|
+ svc := limsreportalertor.GetLimsReportAlertorService(utils.DBE)
|
|
|
+ svc.GetEntityByIdBytbl(this.User.AccCode+LimsReportAlertorName, Id, &model)
|
|
|
+
|
|
|
+ this.Data["json"] = &model
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增
|
|
|
+// @Param body body limsreportalertor.LimsReportAlertor
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /add [post]
|
|
|
+func (this *LimsReportAlertorController) AddEntity() {
|
|
|
+ var model limsreportalertor.LimsReportAlertor
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ svc := limsreportalertor.GetLimsReportAlertorService(utils.DBE)
|
|
|
+
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ model.CreateOn = time.Now()
|
|
|
+ model.CreateBy = this.User.Realname
|
|
|
+ model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
|
|
|
+
|
|
|
+ _, err := svc.InsertEntityBytbl(this.User.AccCode+LimsReportAlertorName, &model)
|
|
|
+
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if err == nil {
|
|
|
+ //新增
|
|
|
+ errinfo.Message = "添加成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Item = model.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 修改实体
|
|
|
+// @Param body body limsreportalertor.LimsReportAlertor
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /update/:id [post]
|
|
|
+func (this *LimsReportAlertorController) UpdateEntity() {
|
|
|
+ id := this.Ctx.Input.Param(":id")
|
|
|
+ var errinfo ErrorInfo
|
|
|
+ if id == "" {
|
|
|
+ errinfo.Message = "操作失败!请求信息不完整"
|
|
|
+ errinfo.Code = -2
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var model limsreportalertor.LimsReportAlertor
|
|
|
+ svc := limsreportalertor.GetLimsReportAlertorService(utils.DBE)
|
|
|
+
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ model.ModifiedOn = time.Now()
|
|
|
+ model.ModifiedBy = this.User.Realname
|
|
|
+ model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+
|
|
|
+ cols := []string{
|
|
|
+
|
|
|
+ "Id",
|
|
|
+
|
|
|
+ "EId",
|
|
|
+
|
|
|
+ "TaskBalanceId",
|
|
|
+
|
|
|
+ "DataEntryId",
|
|
|
+
|
|
|
+ "MeterRange",
|
|
|
+
|
|
|
+ "MeasurementRange",
|
|
|
+
|
|
|
+ "DetectBasis",
|
|
|
+
|
|
|
+ "FaceCheck",
|
|
|
+
|
|
|
+ "FlagCheck",
|
|
|
+
|
|
|
+ "ElectrifyCheck",
|
|
|
+
|
|
|
+ "Insulation",
|
|
|
+
|
|
|
+ "Remark",
|
|
|
+
|
|
|
+ "CreateUserId",
|
|
|
+
|
|
|
+ "CreateOn",
|
|
|
+
|
|
|
+ "CreateBy",
|
|
|
+
|
|
|
+ "ModifiedOn",
|
|
|
+
|
|
|
+ "ModifiedUserId",
|
|
|
+
|
|
|
+ "ModifiedBy",
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ err := svc.UpdateEntityBytbl(this.User.AccCode+LimsReportAlertorName, id, &model, cols)
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 删除单条信息
|
|
|
+// @Description
|
|
|
+// @Success 200 {object} ErrorInfo
|
|
|
+// @Failure 403 :id 为空
|
|
|
+// @router /delete/:Id [delete]
|
|
|
+func (this *LimsReportAlertorController) DeleteEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":Id")
|
|
|
+ var errinfo ErrorInfo
|
|
|
+ if Id == "" {
|
|
|
+ errinfo.Message = "操作失败!请求信息不完整"
|
|
|
+ errinfo.Code = -2
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var model limsreportalertor.LimsReportAlertor
|
|
|
+ var entityempty limsreportalertor.LimsReportAlertor
|
|
|
+ svc := limsreportalertor.GetLimsReportAlertorService(utils.DBE)
|
|
|
+ opdesc := "删除-" + Id
|
|
|
+ err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+LimsReportAlertorName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+}
|