|
|
@@ -0,0 +1,270 @@
|
|
|
+package oilcontract
|
|
|
+
|
|
|
+import (
|
|
|
+ "dashoo.cn/backend/api/business/oilcontract/contractEvaluationOrder"
|
|
|
+ "dashoo.cn/backend/api/business/oilcontract/contractReview"
|
|
|
+ "encoding/json"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "dashoo.cn/backend/api/business/baseUser"
|
|
|
+
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
+ "dashoo.cn/business2/userRole"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+)
|
|
|
+
|
|
|
+type OilContractEvaluationOrderController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取列表
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {object} []evaluationItems.OilEvaluationItems
|
|
|
+// @router /list [get]
|
|
|
+func (this *OilContractEvaluationOrderController) 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")
|
|
|
+ ReviewId := this.GetString("ReviewId")
|
|
|
+ AuditId := this.GetString("AuditId")
|
|
|
+ AuditBy := this.GetString("AuditBy")
|
|
|
+ IsConfirm := this.GetString("IsConfirm")
|
|
|
+ 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 ReviewId != "" {
|
|
|
+ where = where + " and ReviewId like '%" + ReviewId + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ if AuditId != "" {
|
|
|
+ where = where + " and AuditId like '%" + AuditId + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ if AuditBy != "" {
|
|
|
+ where = where + " and AuditBy like '%" + AuditBy + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ if IsConfirm != "" {
|
|
|
+ where = where + " and IsConfirm like '%" + IsConfirm + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 := contractEvaluationOrder.GetOilContractEvaluationOrderService(utils.DBE)
|
|
|
+ var list []contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+ total := svc.GetPagingEntitiesWithOrderBytbl("", 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 *OilContractEvaluationOrderController) 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", "")
|
|
|
+ var userEntity userRole.Base_User
|
|
|
+ userSvc.GetEntityById(this.User.Id, &userEntity)
|
|
|
+ dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
|
|
|
+
|
|
|
+ //var dictCustomer []svccustomer.Customer
|
|
|
+ //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
|
|
|
+ //dictList["EntrustCorp"] = &dictCustomer
|
|
|
+
|
|
|
+ var datainfo DataInfo
|
|
|
+ datainfo.Items = dictList
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取实体
|
|
|
+// @Description 获取实体
|
|
|
+// @Success 200 {object} contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+// @router /get/:id [get]
|
|
|
+func (this *OilContractEvaluationOrderController) GetEntity() {
|
|
|
+ Id := this.Ctx.Input.Param(":id")
|
|
|
+
|
|
|
+ svc := contractEvaluationOrder.GetOilContractEvaluationOrderService(utils.DBE)
|
|
|
+ var model contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+ svc.GetEntityByIdBytbl(OilContractEvaluationOrderName, Id, &model)
|
|
|
+
|
|
|
+ this.Data["json"] = &model
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 添加
|
|
|
+// @Description 创建工单
|
|
|
+// @Param body body contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /add [post]
|
|
|
+func (this *OilContractEvaluationOrderController) AddEntity() {
|
|
|
+ var model contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ svc := contractEvaluationOrder.GetOilContractEvaluationOrderService(utils.DBE)
|
|
|
+
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ model.CreateOn = time.Now()
|
|
|
+ model.CreateBy = this.User.Realname
|
|
|
+ model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ defer func() { //finally处理失败的异常
|
|
|
+ if err := recover(); err != nil {
|
|
|
+ errinfo.Message = err.(string)
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ //返回正确结果
|
|
|
+ errinfo.Message = "添加成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Item = model.Id
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ svc.InsertEntityBytbl(OilContractEvaluationOrderName, &model)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 确认
|
|
|
+// @Description 点击确认
|
|
|
+// @Param body body contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /update/:id [post]
|
|
|
+func (this *OilContractEvaluationOrderController) UpdateEntity() {
|
|
|
+ id := this.Ctx.Input.Param(":id")
|
|
|
+ var errinfo ErrorInfo
|
|
|
+ defer func() { //finally处理失败的异常
|
|
|
+ if err := recover(); err != nil {
|
|
|
+ errinfo.Message = err.(string)
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ //返回正确结果
|
|
|
+ errinfo.Message = "修改成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ if id == "" {
|
|
|
+ panic("操作失败!请求信息不完整")
|
|
|
+ }
|
|
|
+
|
|
|
+ var model contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+ var model1 contractEvaluationOrder.OilContractEvaluationOrder
|
|
|
+ svc := contractEvaluationOrder.GetOilContractEvaluationOrderService(utils.DBE)
|
|
|
+ svc.GetEntityByIdBytbl(OilContractEvaluationOrderName, id, &model1)
|
|
|
+ if model1.IsConfirm == 1 {
|
|
|
+ panic("操作失败!不能再次确认")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取最后一条评价
|
|
|
+ where := " IsFinal = 1 and ContractId = " + strconv.Itoa(model1.ContractId)
|
|
|
+ var contractRev []contractReview.OilContractReview
|
|
|
+ contractSvc := contractReview.GetOilContractReviewService(utils.DBE)
|
|
|
+ contractSvc.GetEntitysByOrderbyWhere(OilContractReviewName, where, "Id Desc", &contractRev)
|
|
|
+ if len(contractRev) <= 0 {
|
|
|
+ panic("操作失败!找不到评价")
|
|
|
+ }
|
|
|
+ var ReviewId int
|
|
|
+ for _, value := range contractRev {
|
|
|
+ if value.Status != "8" {
|
|
|
+ panic("操作失败!审核未结束不能确认")
|
|
|
+ }
|
|
|
+ ReviewId = value.Id
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ model.ReviewId = ReviewId
|
|
|
+ model.IsConfirm = 1
|
|
|
+ model.ModifiedOn = time.Now()
|
|
|
+ model.ModifiedBy = this.User.Realname
|
|
|
+ model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+
|
|
|
+
|
|
|
+ cols := []string{
|
|
|
+ "ReviewId",
|
|
|
+
|
|
|
+ "IsConfirm",
|
|
|
+
|
|
|
+ "ModifiedOn",
|
|
|
+
|
|
|
+ "ModifiedUserId",
|
|
|
+
|
|
|
+ "ModifiedBy",
|
|
|
+ }
|
|
|
+ svc.UpdateEntityBytbl(OilContractEvaluationOrderName, id, &model, cols)
|
|
|
+}
|
|
|
+
|