|
@@ -0,0 +1,305 @@
|
|
|
|
|
+package oilcontract
|
|
|
|
|
+
|
|
|
|
|
+import (
|
|
|
|
|
+ "encoding/json"
|
|
|
|
|
+ "strings"
|
|
|
|
|
+ "time"
|
|
|
|
|
+
|
|
|
|
|
+ "dashoo.cn/backend/api/business/baseUser"
|
|
|
|
|
+ // "dashoo.cn/backend/api/business/items"
|
|
|
|
|
+ "dashoo.cn/backend/api/business/oilcontract/contractSumScore"
|
|
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
|
|
+ "dashoo.cn/business2/userRole"
|
|
|
|
|
+ "dashoo.cn/utils"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+type OilContractSumScoreController struct {
|
|
|
|
|
+ BaseController
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// @Title 获取列表
|
|
|
|
|
+// @Description get user by token
|
|
|
|
|
+// @Success 200 {object} []contractSumScore.OilContractSumScore
|
|
|
|
|
+// @router /list [get]
|
|
|
|
|
+func (this *OilContractSumScoreController) 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")
|
|
|
|
|
+ ContractId := this.GetString("ContractId")
|
|
|
|
|
+ NormalSumScore := this.GetString("NormalSumScore")
|
|
|
|
|
+ SumScore := this.GetString("SumScore")
|
|
|
|
|
+ ConclusionReason := this.GetString("ConclusionReason")
|
|
|
|
|
+ Conclusion := this.GetString("Conclusion")
|
|
|
|
|
+ CreateOn := this.GetString("CreateOn")
|
|
|
|
|
+ CreateUserId := this.GetString("CreateUserId")
|
|
|
|
|
+ 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 ContractId != "" {
|
|
|
|
|
+ where = where + " and ContractId like '%" + ContractId + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if NormalSumScore != "" {
|
|
|
|
|
+ where = where + " and NormalSumScore like '%" + NormalSumScore + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if SumScore != "" {
|
|
|
|
|
+ where = where + " and SumScore like '%" + SumScore + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ConclusionReason != "" {
|
|
|
|
|
+ where = where + " and ConclusionReason like '%" + ConclusionReason + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if Conclusion != "" {
|
|
|
|
|
+ where = where + " and Conclusion like '%" + Conclusion + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if CreateOn != "" {
|
|
|
|
|
+ where = where + " and CreateOn like '%" + CreateOn + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if CreateUserId != "" {
|
|
|
|
|
+ where = where + " and CreateUserId like '%" + CreateUserId + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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 := contractSumScore.GetOilContractSumScoreService(utils.DBE)
|
|
|
|
|
+ var list []contractSumScore.OilContractSumScore
|
|
|
|
|
+ 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 *OilContractSumScoreController) 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} contractSumScore.OilContractSumScore
|
|
|
|
|
+// @router /get/:id [get]
|
|
|
|
|
+func (this *OilContractSumScoreController) GetEntity() {
|
|
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
|
|
+
|
|
|
|
|
+ var model contractSumScore.OilContractSumScore
|
|
|
|
|
+ svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
|
|
|
|
|
+ svc.GetEntityByIdBytbl(this.User.AccCode+OilContractSumScoreName, Id, &model)
|
|
|
|
|
+
|
|
|
|
|
+ this.Data["json"] = &model
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// @Title 添加
|
|
|
|
|
+// @Description 新增
|
|
|
|
|
+// @Param body body contractSumScore.OilContractSumScore
|
|
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
|
|
+// @router /add [post]
|
|
|
|
|
+func (this *OilContractSumScoreController) AddEntity() {
|
|
|
|
|
+ var model contractSumScore.OilContractSumScore
|
|
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
|
|
+ svc := contractSumScore.GetOilContractSumScoreService(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+OilContractSumScoreName, &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 contractSumScore.OilContractSumScore
|
|
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
|
|
+// @router /update/:id [post]
|
|
|
|
|
+func (this *OilContractSumScoreController) 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 contractSumScore.OilContractSumScore
|
|
|
|
|
+ svc := contractSumScore.GetOilContractSumScoreService(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",
|
|
|
|
|
+
|
|
|
|
|
+ "ContractId",
|
|
|
|
|
+
|
|
|
|
|
+ "NormalSumScore",
|
|
|
|
|
+
|
|
|
|
|
+ "SumScore",
|
|
|
|
|
+
|
|
|
|
|
+ "ConclusionReason",
|
|
|
|
|
+
|
|
|
|
|
+ "Conclusion",
|
|
|
|
|
+
|
|
|
|
|
+ "CreateOn",
|
|
|
|
|
+
|
|
|
|
|
+ "CreateUserId",
|
|
|
|
|
+
|
|
|
|
|
+ "CreateBy",
|
|
|
|
|
+
|
|
|
|
|
+ "ModifiedOn",
|
|
|
|
|
+
|
|
|
|
|
+ "ModifiedUserId",
|
|
|
|
|
+
|
|
|
|
|
+ "ModifiedBy",
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ err := svc.UpdateEntityBytbl(this.User.AccCode+OilContractSumScoreName, 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 *OilContractSumScoreController) 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 contractSumScore.OilContractSumScore
|
|
|
|
|
+ var entityempty contractSumScore.OilContractSumScore
|
|
|
|
|
+ svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
|
|
|
|
|
+ opdesc := "删除-" + Id
|
|
|
|
|
+ err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+OilContractSumScoreName, 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()
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|