|
|
@@ -0,0 +1,290 @@
|
|
|
+package oilcontract
|
|
|
+
|
|
|
+import (
|
|
|
+ "dashoo.cn/backend/api/business/oilcontract/contractReviewWorkFlow"
|
|
|
+ "encoding/json"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "dashoo.cn/backend/api/business/baseUser"
|
|
|
+ _ "dashoo.cn/backend/api/business/OilContract/contractReviewWorkFlow"
|
|
|
+ // "dashoo.cn/backend/api/business/items"
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
+ "dashoo.cn/business2/userRole"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+)
|
|
|
+
|
|
|
+type OilContractReviewWorkFlowController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object} []contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+// @router /list [get]
|
|
|
+func (this *OilContractReviewWorkFlowController) 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")
|
|
|
+ ContractEId := this.GetString("ContractEId")
|
|
|
+ WorkflowId := this.GetString("WorkflowId")
|
|
|
+ BusinessKey := this.GetString("BusinessKey")
|
|
|
+ ProcessKey := this.GetString("ProcessKey")
|
|
|
+ BackRemark := this.GetString("BackRemark")
|
|
|
+ ReviewType := this.GetString("ReviewType")
|
|
|
+ CreateOn := this.GetString("CreateOn")
|
|
|
+ CreateUserId := this.GetString("CreateUserId")
|
|
|
+ CreateBy := this.GetString("CreateBy")
|
|
|
+
|
|
|
+ if Id != "" {
|
|
|
+ where = where + " and Id like '%" + Id + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ContractEId != "" {
|
|
|
+ where = where + " and ContractEId like '%" + ContractEId + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if WorkflowId != "" {
|
|
|
+ where = where + " and WorkflowId like '%" + WorkflowId + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if BusinessKey != "" {
|
|
|
+ where = where + " and BusinessKey like '%" + BusinessKey + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ProcessKey != "" {
|
|
|
+ where = where + " and ProcessKey like '%" + ProcessKey + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if BackRemark != "" {
|
|
|
+ where = where + " and BackRemark like '%" + BackRemark + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ReviewType != "" {
|
|
|
+ where = where + " and ReviewType like '%" + ReviewType + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 CreateOn != "" {
|
|
|
+ dates := strings.Split(CreateOn, ",")
|
|
|
+ if len(dates) == 2 {
|
|
|
+ minDate := dates[0]
|
|
|
+ maxDate := dates[1]
|
|
|
+ where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ svc := contractReviewWorkFlow.GetOilContractReviewWorkFlowService(utils.DBE)
|
|
|
+ var list []contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ 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 *OilContractReviewWorkFlowController) 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} contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+// @router /get/:id [get]
|
|
|
+func (this *OilContractReviewWorkFlowController) GetEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+
|
|
|
+ var model contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ svc := contractReviewWorkFlow.GetOilContractReviewWorkFlowService(utils.DBE)
|
|
|
+ svc.GetEntityByIdBytbl(OilContractReviewWorkFlowName, Id, &model)
|
|
|
+
|
|
|
+ this.Data["json"] = &model
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增
|
|
|
+// @Param body body contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /add [post]
|
|
|
+func (this *OilContractReviewWorkFlowController) AddEntity() {
|
|
|
+ var model contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ svc := contractReviewWorkFlow.GetOilContractReviewWorkFlowService(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+OilContractReviewWorkFlowName, &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 contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /update/:id [post]
|
|
|
+func (this *OilContractReviewWorkFlowController) 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 contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ svc := contractReviewWorkFlow.GetOilContractReviewWorkFlowService(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",
|
|
|
+
|
|
|
+ "ContractEId",
|
|
|
+
|
|
|
+ "WorkflowId",
|
|
|
+
|
|
|
+ "BusinessKey",
|
|
|
+
|
|
|
+ "ProcessKey",
|
|
|
+
|
|
|
+ "BackRemark",
|
|
|
+
|
|
|
+ "ReviewType",
|
|
|
+
|
|
|
+ "CreateOn",
|
|
|
+
|
|
|
+ "CreateUserId",
|
|
|
+
|
|
|
+ "CreateBy",
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ err := svc.UpdateEntityBytbl(this.User.AccCode+OilContractReviewWorkFlowName, 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 *OilContractReviewWorkFlowController) 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 contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ var entityempty contractReviewWorkFlow.OilContractReviewWorkFlow
|
|
|
+ svc := contractReviewWorkFlow.GetOilContractReviewWorkFlowService(utils.DBE)
|
|
|
+ opdesc := "删除-" + Id
|
|
|
+ err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+OilContractReviewWorkFlowName, 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()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|