|
|
@@ -0,0 +1,435 @@
|
|
|
+package lims
|
|
|
+
|
|
|
+import (
|
|
|
+"dashoo.cn/business/userRole"
|
|
|
+"dashoo.cn/backend/api/business/baseUser"
|
|
|
+"dashoo.cn/backend/api/business/limsreportmotor"
|
|
|
+. "dashoo.cn/backend/api/controllers"
|
|
|
+"dashoo.cn/utils"
|
|
|
+"encoding/json"
|
|
|
+"strings"
|
|
|
+"time"
|
|
|
+)
|
|
|
+
|
|
|
+type LimsReportMotorController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object} []limsreportmotor.LimsReportMotor
|
|
|
+// @router /list [get]
|
|
|
+func (this *LimsReportMotorController) 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")
|
|
|
+ SectionMonitor := this.GetString("SectionMonitor")
|
|
|
+ MotorType := this.GetString("MotorType")
|
|
|
+ RatedPower := this.GetString("RatedPower")
|
|
|
+ RatedVoltage := this.GetString("RatedVoltage")
|
|
|
+ RatedCurrent := this.GetString("RatedCurrent")
|
|
|
+ RatedSpeed := this.GetString("RatedSpeed")
|
|
|
+ RatedEfficiency := this.GetString("RatedEfficiency")
|
|
|
+ RatedNoloadPower := this.GetString("RatedNoloadPower")
|
|
|
+ RatedPowerFactor := this.GetString("RatedPowerFactor")
|
|
|
+ NoloadCurrent := this.GetString("NoloadCurrent")
|
|
|
+ Insulation := this.GetString("Insulation")
|
|
|
+ Standard := this.GetString("Standard")
|
|
|
+ UseInstrument := this.GetString("UseInstrument")
|
|
|
+ BeforeTesting := this.GetString("BeforeTesting")
|
|
|
+ AfterTesting := this.GetString("AfterTesting")
|
|
|
+ Temperature := this.GetString("Temperature")
|
|
|
+ RelativeHumidity := this.GetString("RelativeHumidity")
|
|
|
+ Voltage := this.GetString("Voltage")
|
|
|
+ Electric := this.GetString("Electric")
|
|
|
+ ActivePower := this.GetString("ActivePower")
|
|
|
+ ReactivePower := this.GetString("ReactivePower")
|
|
|
+ ApparentPower := this.GetString("ApparentPower")
|
|
|
+ PowerFactor := this.GetString("PowerFactor")
|
|
|
+ OperatingEfficiency := this.GetString("OperatingEfficiency")
|
|
|
+ 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 SectionMonitor != "" {
|
|
|
+ where = where + " and SectionMonitor like '%" + SectionMonitor + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if MotorType != "" {
|
|
|
+ where = where + " and MotorType like '%" + MotorType + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedPower != "" {
|
|
|
+ where = where + " and RatedPower like '%" + RatedPower + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedVoltage != "" {
|
|
|
+ where = where + " and RatedVoltage like '%" + RatedVoltage + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedCurrent != "" {
|
|
|
+ where = where + " and RatedCurrent like '%" + RatedCurrent + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedSpeed != "" {
|
|
|
+ where = where + " and RatedSpeed like '%" + RatedSpeed + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedEfficiency != "" {
|
|
|
+ where = where + " and RatedEfficiency like '%" + RatedEfficiency + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedNoloadPower != "" {
|
|
|
+ where = where + " and RatedNoloadPower like '%" + RatedNoloadPower + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RatedPowerFactor != "" {
|
|
|
+ where = where + " and RatedPowerFactor like '%" + RatedPowerFactor + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if NoloadCurrent != "" {
|
|
|
+ where = where + " and NoloadCurrent like '%" + NoloadCurrent + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Insulation != "" {
|
|
|
+ where = where + " and Insulation like '%" + Insulation + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Standard != "" {
|
|
|
+ where = where + " and Standard like '%" + Standard + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if UseInstrument != "" {
|
|
|
+ where = where + " and UseInstrument like '%" + UseInstrument + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if BeforeTesting != "" {
|
|
|
+ where = where + " and BeforeTesting like '%" + BeforeTesting + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if AfterTesting != "" {
|
|
|
+ where = where + " and AfterTesting like '%" + AfterTesting + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Temperature != "" {
|
|
|
+ where = where + " and Temperature like '%" + Temperature + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if RelativeHumidity != "" {
|
|
|
+ where = where + " and RelativeHumidity like '%" + RelativeHumidity + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Voltage != "" {
|
|
|
+ where = where + " and Voltage like '%" + Voltage + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if Electric != "" {
|
|
|
+ where = where + " and Electric like '%" + Electric + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ActivePower != "" {
|
|
|
+ where = where + " and ActivePower like '%" + ActivePower + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ReactivePower != "" {
|
|
|
+ where = where + " and ReactivePower like '%" + ReactivePower + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ApparentPower != "" {
|
|
|
+ where = where + " and ApparentPower like '%" + ApparentPower + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if PowerFactor != "" {
|
|
|
+ where = where + " and PowerFactor like '%" + PowerFactor + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if OperatingEfficiency != "" {
|
|
|
+ where = where + " and OperatingEfficiency like '%" + OperatingEfficiency + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 := limsreportmotor.GetLimsReportMotorService(utils.DBE)
|
|
|
+ var list []limsreportmotor.LimsReportMotor
|
|
|
+ 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 *LimsReportMotorController) 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} limsreportmotor.LimsReportMotor
|
|
|
+// @router /get/:id [get]
|
|
|
+func (this *LimsReportMotorController) GetEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+ where := "DataEntryId=" + Id
|
|
|
+ var model limsreportmotor.LimsReportMotor
|
|
|
+ svc := limsreportmotor.GetLimsReportMotorService(utils.DBE)
|
|
|
+ //svc.GetEntityByIdBytbl(this.User.AccCode+LimsReportMotorName, Id, &model)
|
|
|
+ has := svc.GetEntityByWhere(this.User.AccCode+LimsReportMotorName, where, &model)
|
|
|
+ var data ErrorDataInfo
|
|
|
+ if (has) {
|
|
|
+ data.Code = 0
|
|
|
+ } else {
|
|
|
+ data.Code = -1
|
|
|
+ }
|
|
|
+ data.Item = model
|
|
|
+ this.Data["json"] = &data
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增
|
|
|
+// @Param body body limsreportmotor.LimsReportMotor
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /add [post]
|
|
|
+func (this *LimsReportMotorController) AddEntity() {
|
|
|
+ var model limsreportmotor.LimsReportMotor
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ svc := limsreportmotor.GetLimsReportMotorService(utils.DBE)
|
|
|
+
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ model.CreateOn = time.Now()
|
|
|
+ model.CreateBy = this.User.Realname
|
|
|
+ model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+
|
|
|
+ _, err := svc.InsertEntityBytbl(this.User.AccCode+LimsReportMotorName, &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 limsreportmotor.LimsReportMotor
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /update/:id [post]
|
|
|
+func (this *LimsReportMotorController) 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 limsreportmotor.LimsReportMotor
|
|
|
+ svc := limsreportmotor.GetLimsReportMotorService(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",
|
|
|
+ "SectionMonitor",
|
|
|
+ "MotorType",
|
|
|
+ "RatedPower",
|
|
|
+ "RatedVoltage",
|
|
|
+ "RatedCurrent",
|
|
|
+ "RatedSpeed",
|
|
|
+ "RatedEfficiency",
|
|
|
+ "RatedNoloadPower",
|
|
|
+ "RatedPowerFactor",
|
|
|
+ "NoloadCurrent",
|
|
|
+ "Insulation",
|
|
|
+ "Standard",
|
|
|
+ "UseInstrument",
|
|
|
+ "BeforeTesting",
|
|
|
+ "AfterTesting",
|
|
|
+ "Temperature",
|
|
|
+ "RelativeHumidity",
|
|
|
+ "Voltage",
|
|
|
+ "Electric",
|
|
|
+ "ActivePower",
|
|
|
+ "ReactivePower",
|
|
|
+ "ApparentPower",
|
|
|
+ "PowerFactor",
|
|
|
+ "OperatingEfficiency",
|
|
|
+ "Remark",
|
|
|
+ "CreateUserId",
|
|
|
+ "CreateOn",
|
|
|
+ "CreateBy",
|
|
|
+ "ModifiedOn",
|
|
|
+ "ModifiedUserId",
|
|
|
+ "ModifiedBy",
|
|
|
+ }
|
|
|
+ err := svc.UpdateEntityBytbl(this.User.AccCode+LimsReportMotorName, 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 *LimsReportMotorController) 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 limsreportmotor.LimsReportMotor
|
|
|
+ var entityempty limsreportmotor.LimsReportMotor
|
|
|
+ svc := limsreportmotor.GetLimsReportMotorService(utils.DBE)
|
|
|
+ opdesc := "删除-" + Id
|
|
|
+ err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+LimsReportMotorName, 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()
|
|
|
+ }
|
|
|
+}
|