| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275 |
- package oilcontract
- import (
- "dashoo.cn/backend/api/business/auditsetting"
- "dashoo.cn/backend/api/business/oilcontract/contract"
- "dashoo.cn/backend/api/business/oilcontract/contractEvaluationItems"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/organize"
- "dashoo.cn/business2/permission"
- "log"
- "sync"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilcontract/contractReview"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/workflow"
- "encoding/json"
- "fmt"
- "strconv"
- "strings"
- "time"
- // "dashoo.cn/backend/api/business/items"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- )
- type OilContractReviewController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []contractReview.OilContractReviewWorkFlow
- // @router /list [get]
- func (this *OilContractReviewController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "r.Id"
- asc := " desc "
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = " asc "
- }
- }
- Id := this.GetString("Id")
- ContractClass := this.GetString("ContractClass")
- ContractName := this.GetString("ContractName")
- ProjectOwner := this.GetString("ProjectOwner")
- Telephone := this.GetString("Telephone")
- ContractNo := this.GetString("ContractNo")
- ContractId := this.GetString("ContractId")
- WorkflowId := this.GetString("WorkflowId")
- BusinessKey := this.GetString("BusinessKey")
- ProcessKey := this.GetString("ProcessKey")
- BackRemark := this.GetString("BackRemark")
- CreateOn := this.GetString("CreateOn")
- CreateOn1 := this.GetString("CreateOn1")
- SupplierName := this.GetString("SupplierName")
- SecondUnit := this.GetString("SecondUnit")
- PerformStatus := this.GetString("PerformStatus")
- Status := this.GetString("Status")
- Year := this.GetString("Year")
- Amount := this.GetString("Amount")
- IsAll := this.GetString("IsAll")
- if Id != "" {
- where = where + " and r.Id like '%" + Id + "%'"
- }
- if PerformStatus != "" {
- where = where + " and c.Status=" + PerformStatus + " "
- }
- if Amount != "" {
- where = where + " and c.Amount like '%" + Amount + "%'"
- }
- if ContractClass != "" {
- where = where + " and c.ContractClass = '" + ContractClass + "'"
- }
- if ProjectOwner != "" {
- where = where + " and c.ProjectOwner like '%" + ProjectOwner + "%'"
- }
- if Telephone != "" {
- where = where + " and c.Telephone like '%" + Telephone + "%'"
- }
- if ContractId != "" {
- where = where + " and r.ContractId = '" + ContractId + "'"
- }
- if WorkflowId != "" {
- where = where + " and r.WorkflowId like '%" + WorkflowId + "%'"
- }
- if BusinessKey != "" {
- where = where + " and r.BusinessKey like '%" + BusinessKey + "%'"
- }
- if ProcessKey != "" {
- where = where + " and r.ProcessKey like '%" + ProcessKey + "%'"
- }
- if BackRemark != "" {
- where = where + " and r.BackRemark like '%" + BackRemark + "%'"
- }
- if SupplierName != "" {
- where = where + " and c.SupplierName like '%" + SupplierName + "%'"
- }
- if ContractName != "" {
- where = where + " and c.ContractName like '%" + ContractName + "%'"
- }
- if ContractNo != "" {
- where = where + " and c.ContractNo like '%" + ContractNo + "%'"
- }
- if SecondUnit != "" {
- where = where + " and r.UnitId = " + SecondUnit
- }
- if Status != "" {
- where = where + " and r.Status=" + Status
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and r.CreateOn>='" + minDate + "' and r.CreateOn<='" + maxDate + "'"
- }
- }
- if CreateOn1 != "" {
- dates := strings.Split(CreateOn1, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and c.StartDate>='" + minDate + "' and c.EndDate<='" + maxDate + "'"
- }
- }
- if Year != "" {
- where = where + " and r.CreateOn>='" + Year + "-01-01 00:00:00' and r.CreateOn<='" + Year + "-12-31 23:59:59' "
- }
- //超级管理员和有查看所有数据权限的用户不加条件
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_contract.Review.AllRecord")
- if !isauth {
- // 是否查看本部门的
- if IsAll == "" {
- //根据工作流查找
- //集中评审相关人可看数据
- actisvc := workflow.GetActivitiService(utils.DBE)
- //找出待办任务===准入
- var certIdList string
- ids := actisvc.GetMyTasks(workflow.OIL_DAILY_CONTRACT_EVALUATION, this.User.Id)
- ids1 := actisvc.GetMyTasks(workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS, this.User.Id)
- ids += "," + ids1
- if len(strings.Trim(ids, ",")) > 0 {
- certIdList += strings.Trim(ids, ",") + ","
- }
- certIdList = strings.Trim(certIdList, ",")
- certIdarr := strings.Split(certIdList, ",")
- for i, item := range certIdarr {
- idx := strings.Index(item, "-")
- if idx >= 0 {
- certIdarr[i] = strings.Split(item, "-")[0]
- }
- }
- certIdList = strings.Join(certIdarr, ",")
- if certIdList != "" {
- where += " and ( r.Id in (" + certIdList + ")" + " or r.CreateUserId = '" + this.User.Id + "')"
- } else {
- where = where + " and r.CreateUserId = '" + this.User.Id + "'"
- }
- } else {
- // 权限过滤 自己创建的评价 ,同二级部门创建的评价 ,企管法规处能看
- where = where + " and ( r.CreateUserId = '" + this.User.Id + "' "
- where = where + " or r.UnitId = '" + strconv.Itoa(this.User.UnitId) + "' "
- where = where + " )"
- }
- }
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- var list []contractReview.OilContractReviewListVo
- total := svc.GetContractReviewList(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 *OilContractReviewController) 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} contractReview.OilContractReviewWorkFlow
- // @router /get/:id [get]
- func (this *OilContractReviewController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model contractReview.OilContractReview
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- svc.GetEntityByIdBytbl(OilContractReviewName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Param body body contractReview.OilContractReviewWorkFlow
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilContractReviewController) AddEntity() {
- var modeVO contractReview.OilContractReviewVo
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modeVO)
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
- var reviewMode contractReview.OilContractReview
- reviewMode.IsFinal = modeVO.IsFinal
- reviewMode.IsBusiness = modeVO.IsBusiness
- reviewMode.ContractId = modeVO.ContractId
- reviewMode.Status = "0"
- reviewMode.Unit = this.User.Unit
- reviewMode.UnitId = this.User.UnitId
- reviewMode.CreateOn = time.Now()
- reviewMode.CreateBy = this.User.Realname
- reviewMode.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err := svc.InsertEntityBytbl(OilContractReviewName, &reviewMode)
- var items2 []contractEvaluationItems.OilContractEvaluationItems
- var items3 []contractEvaluationItems.OilContractEvaluationItems
- var items4 []contractEvaluationItems.OilContractEvaluationItems // 业务处室发起评价
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp2 contractEvaluationItems.OilContractEvaluationItems
- temp2.ContentReviewId = reviewMode.Id
- temp2.Type = v.Category
- temp2.Category = 0
- temp2.ItemId = v.Id
- temp2.ParentId = v.ParentId
- temp2.SequenceNo = v.SequenceNo
- temp2.Content = v.Content
- temp2.NormalScore = v.NormalScore
- temp2.Score = v.Score
- temp2.Value = v.Value
- temp2.LevelCode = v.LevelCode
- temp2.Remark = v.Remark
- temp2.Content = v.Content
- temp2.ModifiedOn = time.Now()
- temp2.ModifiedBy = this.User.Realname
- temp2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items2 = append(items2, temp2)
- var temp3 contractEvaluationItems.OilContractEvaluationItems
- temp3.ContentReviewId = reviewMode.Id
- temp3.Type = v.Category
- temp3.Category = 1
- temp3.ItemId = v.Id
- temp3.ParentId = v.ParentId
- temp3.SequenceNo = v.SequenceNo
- temp3.Content = v.Content
- temp3.NormalScore = v.NormalScore
- temp3.Score = v.Score
- temp3.Value = v.Value
- temp3.LevelCode = v.LevelCode
- temp3.Remark = v.Remark
- temp3.Content = v.Content
- temp3.ModifiedOn = time.Now()
- temp3.ModifiedBy = this.User.Realname
- temp3.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items3 = append(items3, temp3)
- // 保存专业处室发起评价
- var temp4 contractEvaluationItems.OilContractEvaluationItems
- temp4.ContentReviewId = reviewMode.Id
- temp4.Type = v.Category
- temp4.Category = 2
- temp4.ItemId = v.Id
- temp4.ParentId = v.ParentId
- temp4.SequenceNo = v.SequenceNo
- temp4.Content = v.Content
- temp4.NormalScore = v.NormalScore
- temp4.Score = v.Score
- temp4.Value = v.Value
- temp4.LevelCode = v.LevelCode
- temp4.Remark = v.Remark
- temp4.Content = v.Content
- temp4.ModifiedOn = time.Now()
- temp4.ModifiedBy = this.User.Realname
- temp4.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items4 = append(items4, temp4)
- }
- errBool := true
- if modeVO.IsBusiness == 0 {
- _, err2 := itemSvc.DBE.Insert(items2)
- // 专业处室评价默认二级
- _, err3 := itemSvc.DBE.Insert(items3)
- if err2 == nil && err3 == nil {
- errBool = false
- }
- }
- if modeVO.IsBusiness == 1 {
- _, err4 := itemSvc.DBE.Insert(items4)
- if err4 == nil {
- errBool = false
- }
- }
- var errinfo ErrorDataInfo
- if err == nil && errBool == false {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = reviewMode.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 从数据录入数据导出到word文档
- // @Description 数据存入word
- // @Success 200 {object} controllers.Request
- // @router /exportword/:id [get]
- func (this *OilContractReviewController) DocExport() {
- // 填物资类信息表首页信息
- Id := this.Ctx.Input.Param(":id")
- var Url string
- var fileName string
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var model contractReview.OilContractReview
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- var items []contractEvaluationItems.OilContractEvaluationItems
- var items1 []contractEvaluationItems.OilContractEvaluationItems
- itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
- var contractModel contract.OilContract
- contractSvc := contract.GetOilContractService(utils.DBE)
- where := " Id = '" + Id + "'"
- svc.GetEntityByWhere(OilContractReviewName, where, &model)
- where3 := " Id= '" + utils.ToStr(model.ContractId) + "' "
- contractSvc.GetEntityByWhere(OilContractName, where3, &contractModel)
- var score = 0.00
- var normalScore = 0.00
- var count = 1.00
- datamap := structToMapDemo(model)
- where2 := " b.ContentReviewId = " + Id + " AND a.Type = '" + contractModel.ContractClass + "'"
- itemSvc.GetSumScore(&items, where2)
- where2 = " ContentReviewId = " + Id
- itemSvc.GetCountItems(&items1, where2)
- if len(items1) == 2 {
- count += 1
- }
- if items != nil {
- for i, v := range items {
- fmt.Print(i)
- fmt.Print(utils.ToStr(v.ItemId))
- if v.Type == 1 {
- Score1, _ := strconv.ParseFloat(v.Score, 64)
- datamap["score_"+utils.ToStr(v.ItemId)] = Score1 / count
- datamap["content_"+utils.ToStr(v.ItemId)] = v.Remark
- if v.ParentId == 0 {
- score = score + (Score1 / count)
- normal, _ := strconv.ParseFloat(v.NormalScore, 64)
- normalScore = normalScore + (normal / count)
- }
- } else {
- datamap["bool_"+utils.ToStr(v.ItemId)] = If(v.Value == 1, "是", "否")
- }
- }
- }
- var supplierEntity supplier.OilSupplier
- supplierSvc := supplier.GetOilSupplierService(utils.DBE)
- supplierSvc.GetEntityByIdBytbl(OilSupplierName, contractModel.SupplierId, &supplierEntity)
- datamap["Score"] = utils.ToStr(score)
- datamap["Standard"] = utils.ToStr(normalScore)
- datamap["Discount"] = score
- if contractModel.Id != 0 {
- datamap["Amount"] = contractModel.Amount
- datamap["SupplierName"] = contractModel.SupplierName
- datamap["ProjectName"] = contractModel.ContractName
- datamap["ContractNo"] = contractModel.ContractNo
- datamap["SubPackage"] = If(contractModel.SubPackage == 1, "是", "否")
- if contractModel.ProjectType == "咨询" {
- datamap["ProjectType"] = "☑咨询 □勘察 □设计 □施工\n□监理 □检测 □工程总承包"
- } else if contractModel.ContractClass == "勘探" {
- datamap["ProjectType"] = "□咨询 ☑勘察 □设计 □施工\n□监理 □检测 □工程总承包"
- } else if contractModel.ContractClass == "设计" {
- datamap["ProjectType"] = "□咨询 □勘察 ☑设计 □施工\n□监理 □检测 □工程总承包"
- } else if contractModel.ContractClass == "施工" {
- datamap["ProjectType"] = "□咨询 □勘察 □设计 ☑施工\n□监理 □检测 □工程总承包"
- }
- datamap["ContractPeriod"] = contractModel.ContractPeriod
- datamap["OpenDate"] = contractModel.OpenDate.Format("2006年01月02日")
- datamap["PlanFinishDate"] = contractModel.PlanFinishDate.Format("2006年01月02日")
- datamap["ConstructionUnit"] = contractModel.ConstructionUnit
- datamap["ConstructionOwner"] = contractModel.ConstructionOwner
- datamap["ConstructionTelphone"] = contractModel.ConstructionTelphone
- }
- if supplierEntity.Id != 0 {
- if supplierEntity.Grade == "一级" {
- datamap["OperType"] = "☑一级供应商 □二级制造商 □二级贸易商 □代理商"
- } else if supplierEntity.OperType == "制造商" {
- datamap["OperType"] = "□一级供应商 ☑二级制造商 □二级贸易商 □代理商"
- } else if supplierEntity.OperType == "代理商" {
- datamap["OperType"] = "□一级供应商 □二级制造商 □二级贸易商 ☑代理商"
- } else if supplierEntity.OperType == "贸易商" {
- datamap["OperType"] = "□一级供应商 □二级制造商 ☑二级贸易商 □代理商"
- }
- }
- // 获取组织名称
- svcorg := organize.GetOrganizeService(utils.DBE)
- datamap["DepartName"] = svcorg.GetNameById(strconv.Itoa(this.User.UnitId))
- fileName = ""
- Url = ""
- if contractModel.ContractClass == "01" {
- fileName = "供应商日常业绩评价表模板.docx"
- Url = utils.Cfg.MustValue("workflow", "reviewGoodsUrl")
- } else if contractModel.ContractClass == "02" {
- fileName = "承包商日常业绩评价表模板.docx"
- Url = utils.Cfg.MustValue("workflow", "reviewBasisUrl")
- } else {
- if contractModel.ClassName == "供用水电气热合同" {
- datamap["OperType"] = "☑水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "仓储保管合同" {
- datamap["OperType"] = "□水电气热 □油田工程 ☑仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "技术合同和知识产权合同" {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n☑技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "运输合同" {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 ☑运输 □服务\n□承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "服务合同" {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 ☑服务\n□承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "承揽合同" {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n☑承揽 □租赁 □其他 "
- } else if contractModel.ClassName == "租赁合同" {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 ☑租赁 □其他 "
- } else {
- datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 ☑其他 "
- }
- fileName = "服务商日常业绩评价表模板.docx"
- Url = utils.Cfg.MustValue("workflow", "reviewServiceUrl")
- }
- t := time.Now()
- datamap["CreateDate"] = t.Format("2006年01月02日")
- datamap["Year"] = t.Format("2006")
- datamap["Creater"] = this.User.Realname
- //datamap["TableComment"] = []string{"MajorEquipments", "ThreeYears", "Patent", "Winning"}
- retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
- //retDocUrl := svcActiviti.FillWordWatermarkTemplate(datamap, Url, fileName, model.SupplierName)
- var datainfo ErrorDataInfo
- datainfo.Code = 0
- datainfo.Item = retDocUrl
- datainfo.Message = "导出成功"
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- func If(condition bool, trueVal, falseVal interface{}) interface{} {
- if condition {
- return trueVal
- }
- return falseVal
- }
- // @Title 添加
- // @Description 业务处室保存评价
- // @Param body body contractReview.OilContractReviewWorkFlow
- // @Success 200 {object} controllers.Request
- // @router /save-sec-evaluation/:id [post]
- func (this *OilContractReviewController) SaveEvaluationItemsBySec() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var modeVO contractReview.OilContractReviewVo
- itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modeVO)
- where := "ContentReviewId=" + id + " AND Category = 1 "
- // 清除掉之前的
- itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
- var items []contractEvaluationItems.OilContractEvaluationItems
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp contractEvaluationItems.OilContractEvaluationItems
- temp.ContentReviewId, _ = strconv.Atoi(id)
- temp.Type = v.Type
- temp.Category = 1
- temp.ItemId = v.ItemId
- temp.ParentId = v.ParentId
- temp.SequenceNo = v.SequenceNo
- temp.Content = v.Content
- temp.NormalScore = v.NormalScore
- temp.Score = v.Score
- temp.Value = v.Value
- temp.LevelCode = v.LevelCode
- temp.Remark = v.Remark
- temp.Content = v.Content
- temp.ModifiedOn = time.Now()
- temp.ModifiedBy = this.User.Realname
- temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items = append(items, temp)
- }
- _, err := itemSvc.DBE.Insert(items)
- 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 企管法规处修改二级单位的评价内容
- // @Param body body contractReview.OilContractReviewWorkFlow
- // @Success 200 {object} controllers.Request
- // @router /prof-update/:id [post]
- func (this *OilContractReviewController) ProfUpdateSecEvaEntity() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var modeVO contractReview.OilContractReviewVo
- itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modeVO)
- where := "ContentReviewId=" + id + " AND Category = 0 "
- // 清除掉之前的
- itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
- var items []contractEvaluationItems.OilContractEvaluationItems
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp contractEvaluationItems.OilContractEvaluationItems
- temp.ContentReviewId, _ = strconv.Atoi(id)
- temp.Type = v.Category //v.Type
- temp.ItemId = v.Id
- temp.Category = 0
- temp.ParentId = v.ParentId
- temp.SequenceNo = v.SequenceNo
- temp.Content = v.Content
- temp.NormalScore = v.NormalScore
- temp.Score = v.Score
- temp.Value = v.Value
- temp.LevelCode = v.LevelCode
- temp.Remark = v.Remark
- temp.Content = v.Content
- temp.ModifiedOn = time.Now()
- temp.ModifiedBy = this.User.Realname
- temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items = append(items, temp)
- }
- _, err := itemSvc.DBE.Insert(items)
- 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 修改实体
- // @Param body body contractReview.OilContractReviewWorkFlow
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilContractReviewController) 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 modeVO contractReview.OilContractReviewVo
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modeVO)
- var reviewMode contractReview.OilContractReview
- reviewMode.ContractId = modeVO.ContractId
- reviewMode.Status = "0"
- reviewMode.ModifiedOn = time.Now()
- reviewMode.ModifiedBy = this.User.Realname
- reviewMode.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "ContractId",
- "BackRemark",
- "FirstAudit",
- "SecondAudit",
- "ThirdAudit",
- "FourthAudit",
- "ProfessionalAudit",
- "AuditIndex",
- "IsFinal",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilContractReviewName, id, &reviewMode, cols)
- errBool := true
- if modeVO.IsBusiness == 0 {
- where := "ContentReviewId=" + id + " AND Category = 0 "
- // 清除掉之前的
- itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
- var items []contractEvaluationItems.OilContractEvaluationItems
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp contractEvaluationItems.OilContractEvaluationItems
- temp.ContentReviewId, _ = strconv.Atoi(id)
- temp.Type = v.Category //v.Type
- temp.ItemId = v.Id
- temp.Category = 0
- temp.ParentId = v.ParentId
- temp.SequenceNo = v.SequenceNo
- temp.Content = v.Content
- temp.NormalScore = v.NormalScore
- temp.Score = v.Score
- temp.Value = v.Value
- temp.LevelCode = v.LevelCode
- temp.Remark = v.Remark
- temp.Content = v.Content
- temp.ModifiedOn = time.Now()
- temp.ModifiedBy = this.User.Realname
- temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items = append(items, temp)
- }
- _, err2 := itemSvc.DBE.Insert(items)
- where2 := "ContentReviewId=" + id + " AND Category = 1 "
- // 清除掉之前的
- itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where2)
- var items2 []contractEvaluationItems.OilContractEvaluationItems
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp2 contractEvaluationItems.OilContractEvaluationItems
- temp2.ContentReviewId, _ = strconv.Atoi(id)
- temp2.Type = v.Category //v.Type
- temp2.ItemId = v.Id
- temp2.Category = 1
- temp2.ParentId = v.ParentId
- temp2.SequenceNo = v.SequenceNo
- temp2.Content = v.Content
- temp2.NormalScore = v.NormalScore
- temp2.Score = v.Score
- temp2.Value = v.Value
- temp2.LevelCode = v.LevelCode
- temp2.Remark = v.Remark
- temp2.Content = v.Content
- temp2.ModifiedOn = time.Now()
- temp2.ModifiedBy = this.User.Realname
- temp2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items2 = append(items2, temp2)
- }
- _, err3 := itemSvc.DBE.Insert(items2)
- if err2 == nil && err3 == nil {
- errBool = false
- }
- }
- if modeVO.IsBusiness == 1 {
- where3 := "ContentReviewId=" + id + " AND Category = 2 "
- // 清除掉之前的
- itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where3)
- var items3 []contractEvaluationItems.OilContractEvaluationItems
- // 新增配置项
- for i, v := range modeVO.Items {
- fmt.Print(i)
- var temp3 contractEvaluationItems.OilContractEvaluationItems
- temp3.ContentReviewId, _ = strconv.Atoi(id)
- temp3.Type = v.Category //v.Type
- temp3.ItemId = v.Id
- temp3.Category = 2
- temp3.ParentId = v.ParentId
- temp3.SequenceNo = v.SequenceNo
- temp3.Content = v.Content
- temp3.NormalScore = v.NormalScore
- temp3.Score = v.Score
- temp3.Value = v.Value
- temp3.LevelCode = v.LevelCode
- temp3.Remark = v.Remark
- temp3.Content = v.Content
- temp3.ModifiedOn = time.Now()
- temp3.ModifiedBy = this.User.Realname
- temp3.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- items3 = append(items3, temp3)
- }
- _, err4 := itemSvc.DBE.Insert(items3)
- if err4 == nil {
- errBool = false
- }
- }
- if err == nil && errBool == false {
- 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 *OilContractReviewController) 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 contractReview.OilContractReview
- var entityempty contractReview.OilContractReview
- svc := contractReview.GetOilContractReviewService(utils.DBE)
- // 评分审核是否结束校验
- svc.GetEntityByIdBytbl(OilContractReviewName, Id, &model)
- if model.Status > "0" && model.Status < "8" {
- errinfo.Message = "该合同评价正在审核,不允许删除!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var setting auditsetting.Base_OilAuditSetting
- orgSvc := organize.GetOrganizeService(utils.DBE)
- whereAudit := "AuditStepCode='PROF_REGULATION'"
- orgSvc.GetEntity(&setting, whereAudit)
- res := orgSvc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId))
- if model.Status == "8" && !res {
- errinfo.Message = "无权删除!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilContractReviewName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- activitiService := workflow.GetActivitiService(utils.DBE)
- var deleteProcessVM workflow.DeleteProcessVM
- if model.WorkflowId != "" && model.WorkflowId != "0" {
- deleteProcessVM.ProcessInstanceId = model.WorkflowId
- if model.Status == "8" {
- deleteProcessVM.DeleteReason = "企管法规处删除日常评价"
- } else {
- deleteProcessVM.DeleteReason = "日常评价审批未通过后,被申请人删除"
- }
- activitiService.DeleteComplete(deleteProcessVM)
- }
- 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} controllers.Request
- // @router /unit-audit/:id [post]
- func (this *OilContractReviewController) UnitAuditEntity() {
- Id := this.Ctx.Input.Param(":id")
- firstAudit := this.GetString("FirstAudit")
- secondAudit := this.GetString("SecondAudit")
- thirdAudit := this.GetString("ThirdAudit")
- AuditRemark := this.GetString("AuditRemark")
- userId := this.User.Id
- var baseUserInfo userRole.Base_User
- userService := userRole.GetUserService(utils.DBE)
- userService.GetEntityById(userId, &baseUserInfo)
- unitId := baseUserInfo.UnitId
- fmt.Println("2222222222")
- 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
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //取出日常评审主表信息
- conRev := contractReview.GetOilContractReviewService(utils.DBE)
- var contractReviewEntity contractReview.OilContractReview
- conRev.GetEntityById(Id, &contractReviewEntity)
- if strconv.Itoa(contractReviewEntity.CreateUserId) != this.User.Id {
- panic("该评价创建人才可提交审核!")
- }
- //检查是否可提交
- //conRev.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.SupplierId), certId)
- //取出合同表
- contractSvc := contract.GetOilContractService(utils.DBE)
- var contractEntity contract.OilContract
- contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- //启动工作流
- businessKey := contractReviewEntity.BusinessKey
- processInstanceId := contractReviewEntity.WorkflowId
- // 如果被驳回,不再新启工作流
- if processInstanceId == "" {
- //启动工作流
- businessKey = Id + "-" + strconv.Itoa(contractReviewEntity.AuditIndex)
- processInstanceId = svcActiviti.StartProcess2(workflow.OIL_DAILY_CONTRACT_EVALUATION, businessKey, this.User.Id, "1", contractEntity.ContractClass, contractEntity.SupplierName)
- if len(processInstanceId) <= 0 {
- panic("工作流启动失败!")
- }
- contractReviewEntity.AuditIndex += 1
- }
- // 将启动和工作流,选择的初审和复审人员保存下来
- cols := []string{
- "Id",
- "FirstAudit",
- "SecondAudit",
- "thirdAudit",
- "WorkflowId",
- "BusinessKey",
- "ProcessKey",
- "CommitComId",
- "AuditIndex",
- }
- contractReviewEntity.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
- contractReviewEntity.BusinessKey = businessKey
- contractReviewEntity.WorkflowId = processInstanceId
- contractReviewEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
- contractReviewEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
- contractReviewEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit)
- contractReviewEntity.CommitComId = strconv.Itoa(unitId)
- conRev.UpdateEntityByIdCols(Id, contractReviewEntity, cols)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
- ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
- ActiComplete.UserId = this.User.Id // 当前审批操作人员
- //ActiComplete.UserNames = secondAudit // 当前审批操作人员
- ActiComplete.Result = "2" //分办提交给二级单位初审
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- }
- // @Title 分办之后的各级审批 --审批 包含:二级单位初审、复审, 业务处室专业审核、企管法规处审核
- // @Description 分办之后的各级审批
- // @Success 200 {object} controllers.Request
- // @router /common-audit/:id [post]
- func (this *OilContractReviewController) CommonAuditEntity() {
- Id := this.Ctx.Input.Param(":id")
- result := this.GetString("result")
- AuditRemark := this.GetString("AuditRemark")
- var errinfo ErrorDataInfo
- if Id == "" {
- errinfo.Message = "请至少选择一条申请进行审批!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- Ids := strings.Split(Id, ",")
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- msg := ""
- if len(Ids) > 1 {
- msg = "审核提交成功,请耐心等待批处理结果!"
- } else {
- msg = "审批成功!"
- }
- if result == "1" {
- errinfo.Message = msg
- } else {
- errinfo.Message = "审批驳回成功!"
- }
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- var lock sync.Mutex
- for i := 0; i < len(Ids); i++ {
- lock.Lock()
- //取出日常评审主表信息
- conRev := contractReview.GetOilContractReviewService(utils.DBE)
- var contractReviewEntity contractReview.OilContractReview
- conRev.GetEntityById(Ids[i], &contractReviewEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- if contractReviewEntity.IsBusiness == 1 {
- ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS // 业务处室分办提交的日常评价
- } else {
- ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION // 二级单位提交的日常评价
- }
- ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
- ActiComplete.UserId = this.User.Id //审批人员
- ActiComplete.Result = result //前台审批[同意、不同意]
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- if len(Ids) > 1 {
- go func() {
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
- }
- }()
- } else {
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
- }
- }
- lock.Unlock()
- }
- }
- // @Title 业务处室接收分办
- // @Description 业务处室接收分办
- // @Success 200 {object} controllers.Request
- // @router /business-separate-audit/:id [post]
- func (this *OilContractReviewController) BusinessOfficeSeparateAuditEntity() {
- Id := this.Ctx.Input.Param(":id")
- Result := this.GetString("Result")
- ProfessionalAudit := this.GetString("ProfessionalAudit")
- AuditRemark := this.GetString("AuditRemark")
- var errInfo ErrorDataInfo
- if Id == "" {
- errInfo.Message = "请至少选择一条申请进行审批!"
- errInfo.Code = -1
- this.Data["json"] = &errInfo
- this.ServeJSON()
- return
- }
- Ids := strings.Split(Id, ",")
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errInfo.Message = err.(string)
- errInfo.Code = -1
- this.Data["json"] = &errInfo
- this.ServeJSON()
- } else {
- //返回正确结果
- msg := ""
- if len(Ids) > 1 {
- msg = "审核提交成功,请耐心等待批处理结果!"
- } else {
- msg = "审批成功!"
- }
- if Result == "1" {
- errInfo.Message = msg
- } else {
- errInfo.Message = "审批驳回成功!"
- }
- errInfo.Code = 0
- this.Data["json"] = &errInfo
- this.ServeJSON()
- }
- }()
- if Result == "1" && ProfessionalAudit == "" {
- panic("请选择审批人")
- }
- var lock sync.Mutex
- for i := 0; i < len(Ids); i++ {
- lock.Lock()
- //取出日常评审主表信息
- conRev := contractReview.GetOilContractReviewService(utils.DBE)
- var contractReviewEntity contractReview.OilContractReview
- conRev.GetEntityById(Ids[i], &contractReviewEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
- ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
- ActiComplete.UserId = this.User.Id //审批人员
- ActiComplete.Result = Result //前台审批[同意、不同意]
- ActiComplete.UserNames = ProfessionalAudit
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- if len(Ids) > 1 {
- go func() {
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
- } else {
- if Result == "1" {
- cols := []string{
- "Id",
- "Status",
- "ProfessionalAudit",
- }
- supplierCertId := strings.Split(contractReviewEntity.BusinessKey, "-")[0]
- contractReviewEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
- contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
- conRev.UpdateEntityByIdCols(supplierCertId, contractReviewEntity, cols)
- fmt.Println("业务处室分办协程!" + strconv.Itoa(i))
- }
- }
- }()
- } else {
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
- } else {
- if Result == "1" {
- cols := []string{
- "Id",
- "Status",
- "ProfessionalAudit",
- }
- supplierCertId := strings.Split(contractReviewEntity.BusinessKey, "-")[0]
- contractReviewEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
- contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
- conRev.UpdateEntityByIdCols(supplierCertId, contractReviewEntity, cols)
- fmt.Println("业务处室分办协程!" + strconv.Itoa(i))
- }
- }
- }
- lock.Unlock()
- }
- }
- // @Title 业务处室提交评价审核
- // @Description 业务处室提交评价审核
- // @Success 200 {object} controllers.Request
- // @router /business-submit-review/:id [post]
- func (this *OilContractReviewController) BusinessSubmitEvaEntity() {
- Id := this.Ctx.Input.Param(":id")
- ProfessionalAudit := this.GetString("ProfessionalAudit")
- AuditRemark := this.GetString("AuditRemark")
- userId := this.User.Id
- var baseUserInfo userRole.Base_User
- userService := userRole.GetUserService(utils.DBE)
- userService.GetEntityById(userId, &baseUserInfo)
- unitId := baseUserInfo.UnitId
- 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
- this.Data["json"] = &errInfo
- this.ServeJSON()
- }
- }()
- if ProfessionalAudit == "" {
- errInfo.Message = "请选择审批人"
- errInfo.Code = -1
- this.Data["json"] = &errInfo
- this.ServeJSON()
- }
- //取出日常评审主表信息
- conRev := contractReview.GetOilContractReviewService(utils.DBE)
- var contractReviewEntity contractReview.OilContractReview
- conRev.GetEntityById(Id, &contractReviewEntity)
- //取出合同表
- contractSvc := contract.GetOilContractService(utils.DBE)
- var contractEntity contract.OilContract
- contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- //启动工作流
- businessKey := contractReviewEntity.BusinessKey
- processInstanceId := contractReviewEntity.WorkflowId
- // 如果被驳回,不再新启工作流
- if processInstanceId == "" {
- //启动工作流
- businessKey = Id + "-" + strconv.Itoa(contractReviewEntity.AuditIndex)
- processInstanceId = svcActiviti.StartProcess2(workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS, businessKey, this.User.Id, "1", contractEntity.ContractClass, contractEntity.SupplierName)
- if len(processInstanceId) <= 0 {
- panic("工作流启动失败!")
- }
- contractReviewEntity.AuditIndex += 1
- }
- // 将启动和工作流,选择的初审和复审人员保存下来
- cols := []string{
- "Id",
- "WorkflowId",
- "BusinessKey",
- "ProcessKey",
- "CommitComId",
- "AuditIndex",
- "ProfessionalAudit",
- }
- contractReviewEntity.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS
- contractReviewEntity.BusinessKey = businessKey
- contractReviewEntity.WorkflowId = processInstanceId
- contractReviewEntity.CommitComId = strconv.Itoa(unitId)
- contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
- conRev.UpdateEntityByIdCols(Id, contractReviewEntity, cols)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS
- ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
- ActiComplete.UserId = this.User.Id // 当前审批操作人员
- ActiComplete.Result = "1" //业务处室分办提交给处室审核
- ActiComplete.UserNames = ProfessionalAudit
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- }
|