2
3

contractReview.go 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. package oilcontract
  2. import (
  3. "dashoo.cn/backend/api/business/auditsetting"
  4. "dashoo.cn/backend/api/business/oilcontract/contract"
  5. "dashoo.cn/backend/api/business/oilcontract/contractEvaluationItems"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  7. "dashoo.cn/backend/api/business/organize"
  8. "dashoo.cn/business2/permission"
  9. "log"
  10. "sync"
  11. "dashoo.cn/backend/api/business/baseUser"
  12. "dashoo.cn/backend/api/business/oilcontract/contractReview"
  13. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  14. "dashoo.cn/backend/api/business/workflow"
  15. "encoding/json"
  16. "fmt"
  17. "strconv"
  18. "strings"
  19. "time"
  20. // "dashoo.cn/backend/api/business/items"
  21. . "dashoo.cn/backend/api/controllers"
  22. "dashoo.cn/business2/userRole"
  23. "dashoo.cn/utils"
  24. )
  25. type OilContractReviewController struct {
  26. BaseController
  27. }
  28. // @Title 获取列表
  29. // @Description get user by token
  30. // @Success 200 {object} []contractReview.OilContractReviewWorkFlow
  31. // @router /list [get]
  32. func (this *OilContractReviewController) GetEntityList() {
  33. //获取分页信息
  34. page := this.GetPageInfoForm()
  35. where := " 1=1 "
  36. orderby := "r.Id"
  37. asc := " desc "
  38. Order := this.GetString("Order")
  39. Prop := this.GetString("Prop")
  40. if Order != "" && Prop != "" {
  41. orderby = Prop
  42. if Order == "asc" {
  43. asc = " asc "
  44. }
  45. }
  46. Id := this.GetString("Id")
  47. ContractClass := this.GetString("ContractClass")
  48. ContractName := this.GetString("ContractName")
  49. ProjectOwner := this.GetString("ProjectOwner")
  50. Telephone := this.GetString("Telephone")
  51. ContractNo := this.GetString("ContractNo")
  52. ContractId := this.GetString("ContractId")
  53. WorkflowId := this.GetString("WorkflowId")
  54. BusinessKey := this.GetString("BusinessKey")
  55. ProcessKey := this.GetString("ProcessKey")
  56. BackRemark := this.GetString("BackRemark")
  57. CreateOn := this.GetString("CreateOn")
  58. CreateOn1 := this.GetString("CreateOn1")
  59. SupplierName := this.GetString("SupplierName")
  60. SecondUnit := this.GetString("SecondUnit")
  61. PerformStatus := this.GetString("PerformStatus")
  62. Status := this.GetString("Status")
  63. Year := this.GetString("Year")
  64. Amount := this.GetString("Amount")
  65. IsAll := this.GetString("IsAll")
  66. if Id != "" {
  67. where = where + " and r.Id like '%" + Id + "%'"
  68. }
  69. if PerformStatus != "" {
  70. where = where + " and c.Status=" + PerformStatus + " "
  71. }
  72. if Amount != "" {
  73. where = where + " and c.Amount like '%" + Amount + "%'"
  74. }
  75. if ContractClass != "" {
  76. where = where + " and c.ContractClass = '" + ContractClass + "'"
  77. }
  78. if ProjectOwner != "" {
  79. where = where + " and c.ProjectOwner like '%" + ProjectOwner + "%'"
  80. }
  81. if Telephone != "" {
  82. where = where + " and c.Telephone like '%" + Telephone + "%'"
  83. }
  84. if ContractId != "" {
  85. where = where + " and r.ContractId = '" + ContractId + "'"
  86. }
  87. if WorkflowId != "" {
  88. where = where + " and r.WorkflowId like '%" + WorkflowId + "%'"
  89. }
  90. if BusinessKey != "" {
  91. where = where + " and r.BusinessKey like '%" + BusinessKey + "%'"
  92. }
  93. if ProcessKey != "" {
  94. where = where + " and r.ProcessKey like '%" + ProcessKey + "%'"
  95. }
  96. if BackRemark != "" {
  97. where = where + " and r.BackRemark like '%" + BackRemark + "%'"
  98. }
  99. if SupplierName != "" {
  100. where = where + " and c.SupplierName like '%" + SupplierName + "%'"
  101. }
  102. if ContractName != "" {
  103. where = where + " and c.ContractName like '%" + ContractName + "%'"
  104. }
  105. if ContractNo != "" {
  106. where = where + " and c.ContractNo like '%" + ContractNo + "%'"
  107. }
  108. if SecondUnit != "" {
  109. where = where + " and r.UnitId = " + SecondUnit
  110. }
  111. if Status != "" {
  112. where = where + " and r.Status=" + Status
  113. }
  114. if CreateOn != "" {
  115. dates := strings.Split(CreateOn, ",")
  116. if len(dates) == 2 {
  117. minDate := dates[0]
  118. maxDate := dates[1]
  119. where = where + " and r.CreateOn>='" + minDate + "' and r.CreateOn<='" + maxDate + "'"
  120. }
  121. }
  122. if CreateOn1 != "" {
  123. dates := strings.Split(CreateOn1, ",")
  124. if len(dates) == 2 {
  125. minDate := dates[0]
  126. maxDate := dates[1]
  127. where = where + " and c.StartDate>='" + minDate + "' and c.EndDate<='" + maxDate + "'"
  128. }
  129. }
  130. if Year != "" {
  131. where = where + " and r.CreateOn>='" + Year + "-01-01 00:00:00' and r.CreateOn<='" + Year + "-12-31 23:59:59' "
  132. }
  133. //超级管理员和有查看所有数据权限的用户不加条件
  134. svcPerm := permission.GetPermissionService(utils.DBE)
  135. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_contract.Review.AllRecord")
  136. if !isauth {
  137. // 是否查看本部门的
  138. if IsAll == "" {
  139. //根据工作流查找
  140. //集中评审相关人可看数据
  141. actisvc := workflow.GetActivitiService(utils.DBE)
  142. //找出待办任务===准入
  143. var certIdList string
  144. ids := actisvc.GetMyTasks(workflow.OIL_DAILY_CONTRACT_EVALUATION, this.User.Id)
  145. ids1 := actisvc.GetMyTasks(workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS, this.User.Id)
  146. ids += "," + ids1
  147. if len(strings.Trim(ids, ",")) > 0 {
  148. certIdList += strings.Trim(ids, ",") + ","
  149. }
  150. certIdList = strings.Trim(certIdList, ",")
  151. certIdarr := strings.Split(certIdList, ",")
  152. for i, item := range certIdarr {
  153. idx := strings.Index(item, "-")
  154. if idx >= 0 {
  155. certIdarr[i] = strings.Split(item, "-")[0]
  156. }
  157. }
  158. certIdList = strings.Join(certIdarr, ",")
  159. if certIdList != "" {
  160. where += " and ( r.Id in (" + certIdList + ")" + " or r.CreateUserId = '" + this.User.Id + "')"
  161. } else {
  162. where = where + " and r.CreateUserId = '" + this.User.Id + "'"
  163. }
  164. } else {
  165. // 权限过滤 自己创建的评价 ,同二级部门创建的评价 ,企管法规处能看
  166. where = where + " and ( r.CreateUserId = '" + this.User.Id + "' "
  167. where = where + " or r.UnitId = '" + strconv.Itoa(this.User.UnitId) + "' "
  168. where = where + " )"
  169. }
  170. }
  171. svc := contractReview.GetOilContractReviewService(utils.DBE)
  172. var list []contractReview.OilContractReviewListVo
  173. total := svc.GetContractReviewList(page.CurrentPage, page.Size, orderby, asc, &list, where)
  174. var datainfo DataInfo
  175. datainfo.Items = list
  176. datainfo.CurrentItemCount = total
  177. datainfo.PageIndex = page.CurrentPage
  178. datainfo.ItemsPerPage = page.Size
  179. this.Data["json"] = &datainfo
  180. this.ServeJSON()
  181. }
  182. // @Title 获取字典列表
  183. // @Description get user by token
  184. // @Success 200 {object} map[string]interface{}
  185. // @router /dictlist [get]
  186. func (this *OilContractReviewController) GetDictList() {
  187. dictList := make(map[string]interface{})
  188. //dictSvc := items.GetItemsService(utils.DBE)
  189. userSvc := baseUser.GetBaseUserService(utils.DBE)
  190. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  191. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
  192. var userEntity userRole.Base_User
  193. userSvc.GetEntityById(this.User.Id, &userEntity)
  194. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  195. //var dictCustomer []svccustomer.Customer
  196. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  197. //dictList["EntrustCorp"] = &dictCustomer
  198. var datainfo DataInfo
  199. datainfo.Items = dictList
  200. this.Data["json"] = &datainfo
  201. this.ServeJSON()
  202. }
  203. // @Title 获取实体
  204. // @Description 获取实体
  205. // @Success 200 {object} contractReview.OilContractReviewWorkFlow
  206. // @router /get/:id [get]
  207. func (this *OilContractReviewController) GetEntity() {
  208. Id := this.Ctx.Input.Param(":id")
  209. var model contractReview.OilContractReview
  210. svc := contractReview.GetOilContractReviewService(utils.DBE)
  211. svc.GetEntityByIdBytbl(OilContractReviewName, Id, &model)
  212. this.Data["json"] = &model
  213. this.ServeJSON()
  214. }
  215. // @Title 添加
  216. // @Description 新增
  217. // @Param body body contractReview.OilContractReviewWorkFlow
  218. // @Success 200 {object} controllers.Request
  219. // @router /add [post]
  220. func (this *OilContractReviewController) AddEntity() {
  221. var modeVO contractReview.OilContractReviewVo
  222. var jsonBlob = this.Ctx.Input.RequestBody
  223. json.Unmarshal(jsonBlob, &modeVO)
  224. svc := contractReview.GetOilContractReviewService(utils.DBE)
  225. itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
  226. var reviewMode contractReview.OilContractReview
  227. reviewMode.IsFinal = modeVO.IsFinal
  228. reviewMode.IsBusiness = modeVO.IsBusiness
  229. reviewMode.ContractId = modeVO.ContractId
  230. reviewMode.Status = "0"
  231. reviewMode.Unit = this.User.Unit
  232. reviewMode.UnitId = this.User.UnitId
  233. reviewMode.CreateOn = time.Now()
  234. reviewMode.CreateBy = this.User.Realname
  235. reviewMode.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  236. _, err := svc.InsertEntityBytbl(OilContractReviewName, &reviewMode)
  237. var items2 []contractEvaluationItems.OilContractEvaluationItems
  238. var items3 []contractEvaluationItems.OilContractEvaluationItems
  239. var items4 []contractEvaluationItems.OilContractEvaluationItems // 业务处室发起评价
  240. // 新增配置项
  241. for i, v := range modeVO.Items {
  242. fmt.Print(i)
  243. var temp2 contractEvaluationItems.OilContractEvaluationItems
  244. temp2.ContentReviewId = reviewMode.Id
  245. temp2.Type = v.Category
  246. temp2.Category = 0
  247. temp2.ItemId = v.Id
  248. temp2.ParentId = v.ParentId
  249. temp2.SequenceNo = v.SequenceNo
  250. temp2.Content = v.Content
  251. temp2.NormalScore = v.NormalScore
  252. temp2.Score = v.Score
  253. temp2.Value = v.Value
  254. temp2.LevelCode = v.LevelCode
  255. temp2.Remark = v.Remark
  256. temp2.Content = v.Content
  257. temp2.ModifiedOn = time.Now()
  258. temp2.ModifiedBy = this.User.Realname
  259. temp2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  260. items2 = append(items2, temp2)
  261. var temp3 contractEvaluationItems.OilContractEvaluationItems
  262. temp3.ContentReviewId = reviewMode.Id
  263. temp3.Type = v.Category
  264. temp3.Category = 1
  265. temp3.ItemId = v.Id
  266. temp3.ParentId = v.ParentId
  267. temp3.SequenceNo = v.SequenceNo
  268. temp3.Content = v.Content
  269. temp3.NormalScore = v.NormalScore
  270. temp3.Score = v.Score
  271. temp3.Value = v.Value
  272. temp3.LevelCode = v.LevelCode
  273. temp3.Remark = v.Remark
  274. temp3.Content = v.Content
  275. temp3.ModifiedOn = time.Now()
  276. temp3.ModifiedBy = this.User.Realname
  277. temp3.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  278. items3 = append(items3, temp3)
  279. // 保存专业处室发起评价
  280. var temp4 contractEvaluationItems.OilContractEvaluationItems
  281. temp4.ContentReviewId = reviewMode.Id
  282. temp4.Type = v.Category
  283. temp4.Category = 2
  284. temp4.ItemId = v.Id
  285. temp4.ParentId = v.ParentId
  286. temp4.SequenceNo = v.SequenceNo
  287. temp4.Content = v.Content
  288. temp4.NormalScore = v.NormalScore
  289. temp4.Score = v.Score
  290. temp4.Value = v.Value
  291. temp4.LevelCode = v.LevelCode
  292. temp4.Remark = v.Remark
  293. temp4.Content = v.Content
  294. temp4.ModifiedOn = time.Now()
  295. temp4.ModifiedBy = this.User.Realname
  296. temp4.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  297. items4 = append(items4, temp4)
  298. }
  299. errBool := true
  300. if modeVO.IsBusiness == 0 {
  301. _, err2 := itemSvc.DBE.Insert(items2)
  302. // 专业处室评价默认二级
  303. _, err3 := itemSvc.DBE.Insert(items3)
  304. if err2 == nil && err3 == nil {
  305. errBool = false
  306. }
  307. }
  308. if modeVO.IsBusiness == 1 {
  309. _, err4 := itemSvc.DBE.Insert(items4)
  310. if err4 == nil {
  311. errBool = false
  312. }
  313. }
  314. var errinfo ErrorDataInfo
  315. if err == nil && errBool == false {
  316. //新增
  317. errinfo.Message = "添加成功!"
  318. errinfo.Code = 0
  319. errinfo.Item = reviewMode.Id
  320. this.Data["json"] = &errinfo
  321. this.ServeJSON()
  322. } else {
  323. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  324. errinfo.Code = -1
  325. this.Data["json"] = &errinfo
  326. this.ServeJSON()
  327. }
  328. }
  329. // @Title 从数据录入数据导出到word文档
  330. // @Description 数据存入word
  331. // @Success 200 {object} controllers.Request
  332. // @router /exportword/:id [get]
  333. func (this *OilContractReviewController) DocExport() {
  334. // 填物资类信息表首页信息
  335. Id := this.Ctx.Input.Param(":id")
  336. var Url string
  337. var fileName string
  338. svcActiviti := workflow.GetActivitiService(utils.DBE)
  339. var model contractReview.OilContractReview
  340. svc := contractReview.GetOilContractReviewService(utils.DBE)
  341. var items []contractEvaluationItems.OilContractEvaluationItems
  342. var items1 []contractEvaluationItems.OilContractEvaluationItems
  343. itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
  344. var contractModel contract.OilContract
  345. contractSvc := contract.GetOilContractService(utils.DBE)
  346. where := " Id = '" + Id + "'"
  347. svc.GetEntityByWhere(OilContractReviewName, where, &model)
  348. where3 := " Id= '" + utils.ToStr(model.ContractId) + "' "
  349. contractSvc.GetEntityByWhere(OilContractName, where3, &contractModel)
  350. var score = 0.00
  351. var normalScore = 0.00
  352. var count = 1.00
  353. datamap := structToMapDemo(model)
  354. where2 := " b.ContentReviewId = " + Id + " AND a.Type = '" + contractModel.ContractClass + "'"
  355. itemSvc.GetSumScore(&items, where2)
  356. where2 = " ContentReviewId = " + Id
  357. itemSvc.GetCountItems(&items1, where2)
  358. if len(items1) == 2 {
  359. count += 1
  360. }
  361. if items != nil {
  362. for i, v := range items {
  363. fmt.Print(i)
  364. fmt.Print(utils.ToStr(v.ItemId))
  365. if v.Type == 1 {
  366. Score1, _ := strconv.ParseFloat(v.Score, 64)
  367. datamap["score_"+utils.ToStr(v.ItemId)] = Score1 / count
  368. datamap["content_"+utils.ToStr(v.ItemId)] = v.Remark
  369. if v.ParentId == 0 {
  370. score = score + (Score1 / count)
  371. normal, _ := strconv.ParseFloat(v.NormalScore, 64)
  372. normalScore = normalScore + (normal / count)
  373. }
  374. } else {
  375. datamap["bool_"+utils.ToStr(v.ItemId)] = If(v.Value == 1, "是", "否")
  376. }
  377. }
  378. }
  379. var supplierEntity supplier.OilSupplier
  380. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  381. supplierSvc.GetEntityByIdBytbl(OilSupplierName, contractModel.SupplierId, &supplierEntity)
  382. datamap["Score"] = utils.ToStr(score)
  383. datamap["Standard"] = utils.ToStr(normalScore)
  384. datamap["Discount"] = score
  385. if contractModel.Id != 0 {
  386. datamap["Amount"] = contractModel.Amount
  387. datamap["SupplierName"] = contractModel.SupplierName
  388. datamap["ProjectName"] = contractModel.ContractName
  389. datamap["ContractNo"] = contractModel.ContractNo
  390. datamap["SubPackage"] = If(contractModel.SubPackage == 1, "是", "否")
  391. if contractModel.ProjectType == "咨询" {
  392. datamap["ProjectType"] = "☑咨询 □勘察 □设计 □施工\n□监理 □检测 □工程总承包"
  393. } else if contractModel.ContractClass == "勘探" {
  394. datamap["ProjectType"] = "□咨询 ☑勘察 □设计 □施工\n□监理 □检测 □工程总承包"
  395. } else if contractModel.ContractClass == "设计" {
  396. datamap["ProjectType"] = "□咨询 □勘察 ☑设计 □施工\n□监理 □检测 □工程总承包"
  397. } else if contractModel.ContractClass == "施工" {
  398. datamap["ProjectType"] = "□咨询 □勘察 □设计 ☑施工\n□监理 □检测 □工程总承包"
  399. }
  400. datamap["ContractPeriod"] = contractModel.ContractPeriod
  401. datamap["OpenDate"] = contractModel.OpenDate.Format("2006年01月02日")
  402. datamap["PlanFinishDate"] = contractModel.PlanFinishDate.Format("2006年01月02日")
  403. datamap["ConstructionUnit"] = contractModel.ConstructionUnit
  404. datamap["ConstructionOwner"] = contractModel.ConstructionOwner
  405. datamap["ConstructionTelphone"] = contractModel.ConstructionTelphone
  406. }
  407. if supplierEntity.Id != 0 {
  408. if supplierEntity.Grade == "一级" {
  409. datamap["OperType"] = "☑一级供应商 □二级制造商 □二级贸易商 □代理商"
  410. } else if supplierEntity.OperType == "制造商" {
  411. datamap["OperType"] = "□一级供应商 ☑二级制造商 □二级贸易商 □代理商"
  412. } else if supplierEntity.OperType == "代理商" {
  413. datamap["OperType"] = "□一级供应商 □二级制造商 □二级贸易商 ☑代理商"
  414. } else if supplierEntity.OperType == "贸易商" {
  415. datamap["OperType"] = "□一级供应商 □二级制造商 ☑二级贸易商 □代理商"
  416. }
  417. }
  418. // 获取组织名称
  419. svcorg := organize.GetOrganizeService(utils.DBE)
  420. datamap["DepartName"] = svcorg.GetNameById(strconv.Itoa(this.User.UnitId))
  421. fileName = ""
  422. Url = ""
  423. if contractModel.ContractClass == "01" {
  424. fileName = "供应商日常业绩评价表模板.docx"
  425. Url = utils.Cfg.MustValue("workflow", "reviewGoodsUrl")
  426. } else if contractModel.ContractClass == "02" {
  427. fileName = "承包商日常业绩评价表模板.docx"
  428. Url = utils.Cfg.MustValue("workflow", "reviewBasisUrl")
  429. } else {
  430. if contractModel.ClassName == "供用水电气热合同" {
  431. datamap["OperType"] = "☑水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
  432. } else if contractModel.ClassName == "仓储保管合同" {
  433. datamap["OperType"] = "□水电气热 □油田工程 ☑仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
  434. } else if contractModel.ClassName == "技术合同和知识产权合同" {
  435. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n☑技术和知识产权 □运输 □服务\n□承揽 □租赁 □其他 "
  436. } else if contractModel.ClassName == "运输合同" {
  437. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 ☑运输 □服务\n□承揽 □租赁 □其他 "
  438. } else if contractModel.ClassName == "服务合同" {
  439. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 ☑服务\n□承揽 □租赁 □其他 "
  440. } else if contractModel.ClassName == "承揽合同" {
  441. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n☑承揽 □租赁 □其他 "
  442. } else if contractModel.ClassName == "租赁合同" {
  443. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 ☑租赁 □其他 "
  444. } else {
  445. datamap["OperType"] = "□水电气热 □油田工程 □仓储保管\n□技术和知识产权 □运输 □服务\n□承揽 □租赁 ☑其他 "
  446. }
  447. fileName = "服务商日常业绩评价表模板.docx"
  448. Url = utils.Cfg.MustValue("workflow", "reviewServiceUrl")
  449. }
  450. t := time.Now()
  451. datamap["CreateDate"] = t.Format("2006年01月02日")
  452. datamap["Year"] = t.Format("2006")
  453. datamap["Creater"] = this.User.Realname
  454. //datamap["TableComment"] = []string{"MajorEquipments", "ThreeYears", "Patent", "Winning"}
  455. retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
  456. //retDocUrl := svcActiviti.FillWordWatermarkTemplate(datamap, Url, fileName, model.SupplierName)
  457. var datainfo ErrorDataInfo
  458. datainfo.Code = 0
  459. datainfo.Item = retDocUrl
  460. datainfo.Message = "导出成功"
  461. this.Data["json"] = &datainfo
  462. this.ServeJSON()
  463. }
  464. func If(condition bool, trueVal, falseVal interface{}) interface{} {
  465. if condition {
  466. return trueVal
  467. }
  468. return falseVal
  469. }
  470. // @Title 添加
  471. // @Description 业务处室保存评价
  472. // @Param body body contractReview.OilContractReviewWorkFlow
  473. // @Success 200 {object} controllers.Request
  474. // @router /save-sec-evaluation/:id [post]
  475. func (this *OilContractReviewController) SaveEvaluationItemsBySec() {
  476. id := this.Ctx.Input.Param(":id")
  477. var errinfo ErrorInfo
  478. if id == "" {
  479. errinfo.Message = "操作失败!请求信息不完整"
  480. errinfo.Code = -2
  481. this.Data["json"] = &errinfo
  482. this.ServeJSON()
  483. return
  484. }
  485. var modeVO contractReview.OilContractReviewVo
  486. itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
  487. var jsonBlob = this.Ctx.Input.RequestBody
  488. json.Unmarshal(jsonBlob, &modeVO)
  489. where := "ContentReviewId=" + id + " AND Category = 1 "
  490. // 清除掉之前的
  491. itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
  492. var items []contractEvaluationItems.OilContractEvaluationItems
  493. // 新增配置项
  494. for i, v := range modeVO.Items {
  495. fmt.Print(i)
  496. var temp contractEvaluationItems.OilContractEvaluationItems
  497. temp.ContentReviewId, _ = strconv.Atoi(id)
  498. temp.Type = v.Type
  499. temp.Category = 1
  500. temp.ItemId = v.ItemId
  501. temp.ParentId = v.ParentId
  502. temp.SequenceNo = v.SequenceNo
  503. temp.Content = v.Content
  504. temp.NormalScore = v.NormalScore
  505. temp.Score = v.Score
  506. temp.Value = v.Value
  507. temp.LevelCode = v.LevelCode
  508. temp.Remark = v.Remark
  509. temp.Content = v.Content
  510. temp.ModifiedOn = time.Now()
  511. temp.ModifiedBy = this.User.Realname
  512. temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  513. items = append(items, temp)
  514. }
  515. _, err := itemSvc.DBE.Insert(items)
  516. if err == nil {
  517. errinfo.Message = "修改成功!"
  518. errinfo.Code = 0
  519. this.Data["json"] = &errinfo
  520. this.ServeJSON()
  521. } else {
  522. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  523. errinfo.Code = -1
  524. this.Data["json"] = &errinfo
  525. this.ServeJSON()
  526. }
  527. }
  528. // @Title 修改实体
  529. // @Description 企管法规处修改二级单位的评价内容
  530. // @Param body body contractReview.OilContractReviewWorkFlow
  531. // @Success 200 {object} controllers.Request
  532. // @router /prof-update/:id [post]
  533. func (this *OilContractReviewController) ProfUpdateSecEvaEntity() {
  534. id := this.Ctx.Input.Param(":id")
  535. var errinfo ErrorInfo
  536. if id == "" {
  537. errinfo.Message = "操作失败!请求信息不完整"
  538. errinfo.Code = -2
  539. this.Data["json"] = &errinfo
  540. this.ServeJSON()
  541. return
  542. }
  543. var modeVO contractReview.OilContractReviewVo
  544. itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
  545. var jsonBlob = this.Ctx.Input.RequestBody
  546. json.Unmarshal(jsonBlob, &modeVO)
  547. where := "ContentReviewId=" + id + " AND Category = 0 "
  548. // 清除掉之前的
  549. itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
  550. var items []contractEvaluationItems.OilContractEvaluationItems
  551. // 新增配置项
  552. for i, v := range modeVO.Items {
  553. fmt.Print(i)
  554. var temp contractEvaluationItems.OilContractEvaluationItems
  555. temp.ContentReviewId, _ = strconv.Atoi(id)
  556. temp.Type = v.Category //v.Type
  557. temp.ItemId = v.Id
  558. temp.Category = 0
  559. temp.ParentId = v.ParentId
  560. temp.SequenceNo = v.SequenceNo
  561. temp.Content = v.Content
  562. temp.NormalScore = v.NormalScore
  563. temp.Score = v.Score
  564. temp.Value = v.Value
  565. temp.LevelCode = v.LevelCode
  566. temp.Remark = v.Remark
  567. temp.Content = v.Content
  568. temp.ModifiedOn = time.Now()
  569. temp.ModifiedBy = this.User.Realname
  570. temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  571. items = append(items, temp)
  572. }
  573. _, err := itemSvc.DBE.Insert(items)
  574. if err == nil {
  575. errinfo.Message = "修改成功!"
  576. errinfo.Code = 0
  577. this.Data["json"] = &errinfo
  578. this.ServeJSON()
  579. } else {
  580. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  581. errinfo.Code = -1
  582. this.Data["json"] = &errinfo
  583. this.ServeJSON()
  584. }
  585. }
  586. // @Title 修改实体
  587. // @Description 修改实体
  588. // @Param body body contractReview.OilContractReviewWorkFlow
  589. // @Success 200 {object} controllers.Request
  590. // @router /update/:id [post]
  591. func (this *OilContractReviewController) UpdateEntity() {
  592. id := this.Ctx.Input.Param(":id")
  593. var errinfo ErrorInfo
  594. if id == "" {
  595. errinfo.Message = "操作失败!请求信息不完整"
  596. errinfo.Code = -2
  597. this.Data["json"] = &errinfo
  598. this.ServeJSON()
  599. return
  600. }
  601. var modeVO contractReview.OilContractReviewVo
  602. svc := contractReview.GetOilContractReviewService(utils.DBE)
  603. itemSvc := contractEvaluationItems.GetOilContractEvaluationItemsService(utils.DBE)
  604. var jsonBlob = this.Ctx.Input.RequestBody
  605. json.Unmarshal(jsonBlob, &modeVO)
  606. var reviewMode contractReview.OilContractReview
  607. reviewMode.ContractId = modeVO.ContractId
  608. reviewMode.Status = "0"
  609. reviewMode.ModifiedOn = time.Now()
  610. reviewMode.ModifiedBy = this.User.Realname
  611. reviewMode.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  612. cols := []string{
  613. "Id",
  614. "ContractId",
  615. "BackRemark",
  616. "FirstAudit",
  617. "SecondAudit",
  618. "ThirdAudit",
  619. "FourthAudit",
  620. "ProfessionalAudit",
  621. "AuditIndex",
  622. "IsFinal",
  623. "ModifiedOn",
  624. "ModifiedUserId",
  625. "ModifiedBy",
  626. }
  627. err := svc.UpdateEntityBytbl(OilContractReviewName, id, &reviewMode, cols)
  628. errBool := true
  629. if modeVO.IsBusiness == 0 {
  630. where := "ContentReviewId=" + id + " AND Category = 0 "
  631. // 清除掉之前的
  632. itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
  633. var items []contractEvaluationItems.OilContractEvaluationItems
  634. // 新增配置项
  635. for i, v := range modeVO.Items {
  636. fmt.Print(i)
  637. var temp contractEvaluationItems.OilContractEvaluationItems
  638. temp.ContentReviewId, _ = strconv.Atoi(id)
  639. temp.Type = v.Category //v.Type
  640. temp.ItemId = v.Id
  641. temp.Category = 0
  642. temp.ParentId = v.ParentId
  643. temp.SequenceNo = v.SequenceNo
  644. temp.Content = v.Content
  645. temp.NormalScore = v.NormalScore
  646. temp.Score = v.Score
  647. temp.Value = v.Value
  648. temp.LevelCode = v.LevelCode
  649. temp.Remark = v.Remark
  650. temp.Content = v.Content
  651. temp.ModifiedOn = time.Now()
  652. temp.ModifiedBy = this.User.Realname
  653. temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  654. items = append(items, temp)
  655. }
  656. _, err2 := itemSvc.DBE.Insert(items)
  657. where2 := "ContentReviewId=" + id + " AND Category = 1 "
  658. // 清除掉之前的
  659. itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where2)
  660. var items2 []contractEvaluationItems.OilContractEvaluationItems
  661. // 新增配置项
  662. for i, v := range modeVO.Items {
  663. fmt.Print(i)
  664. var temp2 contractEvaluationItems.OilContractEvaluationItems
  665. temp2.ContentReviewId, _ = strconv.Atoi(id)
  666. temp2.Type = v.Category //v.Type
  667. temp2.ItemId = v.Id
  668. temp2.Category = 1
  669. temp2.ParentId = v.ParentId
  670. temp2.SequenceNo = v.SequenceNo
  671. temp2.Content = v.Content
  672. temp2.NormalScore = v.NormalScore
  673. temp2.Score = v.Score
  674. temp2.Value = v.Value
  675. temp2.LevelCode = v.LevelCode
  676. temp2.Remark = v.Remark
  677. temp2.Content = v.Content
  678. temp2.ModifiedOn = time.Now()
  679. temp2.ModifiedBy = this.User.Realname
  680. temp2.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  681. items2 = append(items2, temp2)
  682. }
  683. _, err3 := itemSvc.DBE.Insert(items2)
  684. if err2 == nil && err3 == nil {
  685. errBool = false
  686. }
  687. }
  688. if modeVO.IsBusiness == 1 {
  689. where3 := "ContentReviewId=" + id + " AND Category = 2 "
  690. // 清除掉之前的
  691. itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where3)
  692. var items3 []contractEvaluationItems.OilContractEvaluationItems
  693. // 新增配置项
  694. for i, v := range modeVO.Items {
  695. fmt.Print(i)
  696. var temp3 contractEvaluationItems.OilContractEvaluationItems
  697. temp3.ContentReviewId, _ = strconv.Atoi(id)
  698. temp3.Type = v.Category //v.Type
  699. temp3.ItemId = v.Id
  700. temp3.Category = 2
  701. temp3.ParentId = v.ParentId
  702. temp3.SequenceNo = v.SequenceNo
  703. temp3.Content = v.Content
  704. temp3.NormalScore = v.NormalScore
  705. temp3.Score = v.Score
  706. temp3.Value = v.Value
  707. temp3.LevelCode = v.LevelCode
  708. temp3.Remark = v.Remark
  709. temp3.Content = v.Content
  710. temp3.ModifiedOn = time.Now()
  711. temp3.ModifiedBy = this.User.Realname
  712. temp3.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  713. items3 = append(items3, temp3)
  714. }
  715. _, err4 := itemSvc.DBE.Insert(items3)
  716. if err4 == nil {
  717. errBool = false
  718. }
  719. }
  720. if err == nil && errBool == false {
  721. errinfo.Message = "修改成功!"
  722. errinfo.Code = 0
  723. this.Data["json"] = &errinfo
  724. this.ServeJSON()
  725. } else {
  726. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  727. errinfo.Code = -1
  728. this.Data["json"] = &errinfo
  729. this.ServeJSON()
  730. }
  731. }
  732. // @Title 删除单条信息
  733. // @Description
  734. // @Success 200 {object} ErrorInfo
  735. // @Failure 403 :id 为空
  736. // @router /delete/:Id [delete]
  737. func (this *OilContractReviewController) DeleteEntity() {
  738. Id := this.Ctx.Input.Param(":Id")
  739. var errinfo ErrorInfo
  740. if Id == "" {
  741. errinfo.Message = "操作失败!请求信息不完整"
  742. errinfo.Code = -2
  743. this.Data["json"] = &errinfo
  744. this.ServeJSON()
  745. return
  746. }
  747. var model contractReview.OilContractReview
  748. var entityempty contractReview.OilContractReview
  749. svc := contractReview.GetOilContractReviewService(utils.DBE)
  750. // 评分审核是否结束校验
  751. svc.GetEntityByIdBytbl(OilContractReviewName, Id, &model)
  752. if model.Status > "0" && model.Status < "8" {
  753. errinfo.Message = "该合同评价正在审核,不允许删除!"
  754. errinfo.Code = -1
  755. this.Data["json"] = &errinfo
  756. this.ServeJSON()
  757. return
  758. }
  759. var setting auditsetting.Base_OilAuditSetting
  760. orgSvc := organize.GetOrganizeService(utils.DBE)
  761. whereAudit := "AuditStepCode='PROF_REGULATION'"
  762. orgSvc.GetEntity(&setting, whereAudit)
  763. res := orgSvc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId))
  764. if model.Status == "8" && !res {
  765. errinfo.Message = "无权删除!"
  766. errinfo.Code = -1
  767. this.Data["json"] = &errinfo
  768. this.ServeJSON()
  769. return
  770. }
  771. opdesc := "删除-" + Id
  772. err := svc.DeleteOperationAndWriteLogBytbl(OilContractReviewName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  773. if err == nil {
  774. activitiService := workflow.GetActivitiService(utils.DBE)
  775. var deleteProcessVM workflow.DeleteProcessVM
  776. if model.WorkflowId != "" && model.WorkflowId != "0" {
  777. deleteProcessVM.ProcessInstanceId = model.WorkflowId
  778. if model.Status == "8" {
  779. deleteProcessVM.DeleteReason = "企管法规处删除日常评价"
  780. } else {
  781. deleteProcessVM.DeleteReason = "日常评价审批未通过后,被申请人删除"
  782. }
  783. activitiService.DeleteComplete(deleteProcessVM)
  784. }
  785. errinfo.Message = "删除成功"
  786. errinfo.Code = 0
  787. this.Data["json"] = &errinfo
  788. this.ServeJSON()
  789. } else {
  790. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  791. errinfo.Code = -1
  792. this.Data["json"] = &errinfo
  793. this.ServeJSON()
  794. }
  795. }
  796. // @Title 二级单位提交审批 --启动工作流
  797. // @Description 二级单位提交审批
  798. // @Success 200 {object} controllers.Request
  799. // @router /unit-audit/:id [post]
  800. func (this *OilContractReviewController) UnitAuditEntity() {
  801. Id := this.Ctx.Input.Param(":id")
  802. firstAudit := this.GetString("FirstAudit")
  803. secondAudit := this.GetString("SecondAudit")
  804. thirdAudit := this.GetString("ThirdAudit")
  805. AuditRemark := this.GetString("AuditRemark")
  806. userId := this.User.Id
  807. var baseUserInfo userRole.Base_User
  808. userService := userRole.GetUserService(utils.DBE)
  809. userService.GetEntityById(userId, &baseUserInfo)
  810. unitId := baseUserInfo.UnitId
  811. fmt.Println("2222222222")
  812. var errinfo ErrorDataInfo
  813. defer func() { //finally处理失败的异常
  814. if err := recover(); err != nil {
  815. errinfo.Message = err.(string)
  816. errinfo.Code = -1
  817. this.Data["json"] = &errinfo
  818. this.ServeJSON()
  819. } else {
  820. //返回正确结果
  821. errinfo.Message = "审核提交成功"
  822. errinfo.Code = 0
  823. this.Data["json"] = &errinfo
  824. this.ServeJSON()
  825. }
  826. }()
  827. //取出日常评审主表信息
  828. conRev := contractReview.GetOilContractReviewService(utils.DBE)
  829. var contractReviewEntity contractReview.OilContractReview
  830. conRev.GetEntityById(Id, &contractReviewEntity)
  831. if strconv.Itoa(contractReviewEntity.CreateUserId) != this.User.Id {
  832. panic("该评价创建人才可提交审核!")
  833. }
  834. //检查是否可提交
  835. //conRev.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.SupplierId), certId)
  836. //取出合同表
  837. contractSvc := contract.GetOilContractService(utils.DBE)
  838. var contractEntity contract.OilContract
  839. contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
  840. svcActiviti := workflow.GetActivitiService(utils.DBE)
  841. //启动工作流
  842. businessKey := contractReviewEntity.BusinessKey
  843. processInstanceId := contractReviewEntity.WorkflowId
  844. // 如果被驳回,不再新启工作流
  845. if processInstanceId == "" {
  846. //启动工作流
  847. businessKey = Id + "-" + strconv.Itoa(contractReviewEntity.AuditIndex)
  848. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_DAILY_CONTRACT_EVALUATION, businessKey, this.User.Id, "1", contractEntity.ContractClass, contractEntity.SupplierName)
  849. if len(processInstanceId) <= 0 {
  850. panic("工作流启动失败!")
  851. }
  852. contractReviewEntity.AuditIndex += 1
  853. }
  854. // 将启动和工作流,选择的初审和复审人员保存下来
  855. cols := []string{
  856. "Id",
  857. "FirstAudit",
  858. "SecondAudit",
  859. "thirdAudit",
  860. "WorkflowId",
  861. "BusinessKey",
  862. "ProcessKey",
  863. "CommitComId",
  864. "AuditIndex",
  865. }
  866. contractReviewEntity.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
  867. contractReviewEntity.BusinessKey = businessKey
  868. contractReviewEntity.WorkflowId = processInstanceId
  869. contractReviewEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  870. contractReviewEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
  871. contractReviewEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit)
  872. contractReviewEntity.CommitComId = strconv.Itoa(unitId)
  873. conRev.UpdateEntityByIdCols(Id, contractReviewEntity, cols)
  874. var ActiComplete workflow.ActiCompleteVM
  875. ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
  876. ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
  877. ActiComplete.UserId = this.User.Id // 当前审批操作人员
  878. //ActiComplete.UserNames = secondAudit // 当前审批操作人员
  879. ActiComplete.Result = "2" //分办提交给二级单位初审
  880. ActiComplete.Remarks = AuditRemark
  881. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  882. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  883. if receiveVal != "true" {
  884. panic("工作流异常,请联系管理员!" + receiveVal)
  885. }
  886. }
  887. // @Title 分办之后的各级审批 --审批 包含:二级单位初审、复审, 业务处室专业审核、企管法规处审核
  888. // @Description 分办之后的各级审批
  889. // @Success 200 {object} controllers.Request
  890. // @router /common-audit/:id [post]
  891. func (this *OilContractReviewController) CommonAuditEntity() {
  892. Id := this.Ctx.Input.Param(":id")
  893. result := this.GetString("result")
  894. AuditRemark := this.GetString("AuditRemark")
  895. var errinfo ErrorDataInfo
  896. if Id == "" {
  897. errinfo.Message = "请至少选择一条申请进行审批!"
  898. errinfo.Code = -1
  899. this.Data["json"] = &errinfo
  900. this.ServeJSON()
  901. return
  902. }
  903. Ids := strings.Split(Id, ",")
  904. defer func() { //finally处理失败的异常
  905. if err := recover(); err != nil {
  906. errinfo.Message = err.(string)
  907. errinfo.Code = -1
  908. this.Data["json"] = &errinfo
  909. this.ServeJSON()
  910. } else {
  911. //返回正确结果
  912. msg := ""
  913. if len(Ids) > 1 {
  914. msg = "审核提交成功,请耐心等待批处理结果!"
  915. } else {
  916. msg = "审批成功!"
  917. }
  918. if result == "1" {
  919. errinfo.Message = msg
  920. } else {
  921. errinfo.Message = "审批驳回成功!"
  922. }
  923. errinfo.Code = 0
  924. this.Data["json"] = &errinfo
  925. this.ServeJSON()
  926. }
  927. }()
  928. var lock sync.Mutex
  929. for i := 0; i < len(Ids); i++ {
  930. lock.Lock()
  931. //取出日常评审主表信息
  932. conRev := contractReview.GetOilContractReviewService(utils.DBE)
  933. var contractReviewEntity contractReview.OilContractReview
  934. conRev.GetEntityById(Ids[i], &contractReviewEntity)
  935. svcActiviti := workflow.GetActivitiService(utils.DBE)
  936. var ActiComplete workflow.ActiCompleteVM
  937. if contractReviewEntity.IsBusiness == 1 {
  938. ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS // 业务处室分办提交的日常评价
  939. } else {
  940. ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION // 二级单位提交的日常评价
  941. }
  942. ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
  943. ActiComplete.UserId = this.User.Id //审批人员
  944. ActiComplete.Result = result //前台审批[同意、不同意]
  945. ActiComplete.Remarks = AuditRemark
  946. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  947. if len(Ids) > 1 {
  948. go func() {
  949. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  950. if receiveVal != "true" {
  951. log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
  952. }
  953. }()
  954. } else {
  955. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  956. if receiveVal != "true" {
  957. log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
  958. }
  959. }
  960. lock.Unlock()
  961. }
  962. }
  963. // @Title 业务处室接收分办
  964. // @Description 业务处室接收分办
  965. // @Success 200 {object} controllers.Request
  966. // @router /business-separate-audit/:id [post]
  967. func (this *OilContractReviewController) BusinessOfficeSeparateAuditEntity() {
  968. Id := this.Ctx.Input.Param(":id")
  969. Result := this.GetString("Result")
  970. ProfessionalAudit := this.GetString("ProfessionalAudit")
  971. AuditRemark := this.GetString("AuditRemark")
  972. var errInfo ErrorDataInfo
  973. if Id == "" {
  974. errInfo.Message = "请至少选择一条申请进行审批!"
  975. errInfo.Code = -1
  976. this.Data["json"] = &errInfo
  977. this.ServeJSON()
  978. return
  979. }
  980. Ids := strings.Split(Id, ",")
  981. defer func() { //finally处理失败的异常
  982. if err := recover(); err != nil {
  983. errInfo.Message = err.(string)
  984. errInfo.Code = -1
  985. this.Data["json"] = &errInfo
  986. this.ServeJSON()
  987. } else {
  988. //返回正确结果
  989. msg := ""
  990. if len(Ids) > 1 {
  991. msg = "审核提交成功,请耐心等待批处理结果!"
  992. } else {
  993. msg = "审批成功!"
  994. }
  995. if Result == "1" {
  996. errInfo.Message = msg
  997. } else {
  998. errInfo.Message = "审批驳回成功!"
  999. }
  1000. errInfo.Code = 0
  1001. this.Data["json"] = &errInfo
  1002. this.ServeJSON()
  1003. }
  1004. }()
  1005. if Result == "1" && ProfessionalAudit == "" {
  1006. panic("请选择审批人")
  1007. }
  1008. var lock sync.Mutex
  1009. for i := 0; i < len(Ids); i++ {
  1010. lock.Lock()
  1011. //取出日常评审主表信息
  1012. conRev := contractReview.GetOilContractReviewService(utils.DBE)
  1013. var contractReviewEntity contractReview.OilContractReview
  1014. conRev.GetEntityById(Ids[i], &contractReviewEntity)
  1015. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1016. var ActiComplete workflow.ActiCompleteVM
  1017. ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVALUATION
  1018. ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
  1019. ActiComplete.UserId = this.User.Id //审批人员
  1020. ActiComplete.Result = Result //前台审批[同意、不同意]
  1021. ActiComplete.UserNames = ProfessionalAudit
  1022. ActiComplete.Remarks = AuditRemark
  1023. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1024. if len(Ids) > 1 {
  1025. go func() {
  1026. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1027. if receiveVal != "true" {
  1028. log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
  1029. } else {
  1030. if Result == "1" {
  1031. cols := []string{
  1032. "Id",
  1033. "Status",
  1034. "ProfessionalAudit",
  1035. }
  1036. supplierCertId := strings.Split(contractReviewEntity.BusinessKey, "-")[0]
  1037. contractReviewEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
  1038. contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
  1039. conRev.UpdateEntityByIdCols(supplierCertId, contractReviewEntity, cols)
  1040. fmt.Println("业务处室分办协程!" + strconv.Itoa(i))
  1041. }
  1042. }
  1043. }()
  1044. } else {
  1045. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1046. if receiveVal != "true" {
  1047. log.Print("日常评价 工作流异常,业务ID:" + contractReviewEntity.BusinessKey + ",工作流信息:" + receiveVal)
  1048. } else {
  1049. if Result == "1" {
  1050. cols := []string{
  1051. "Id",
  1052. "Status",
  1053. "ProfessionalAudit",
  1054. }
  1055. supplierCertId := strings.Split(contractReviewEntity.BusinessKey, "-")[0]
  1056. contractReviewEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
  1057. contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
  1058. conRev.UpdateEntityByIdCols(supplierCertId, contractReviewEntity, cols)
  1059. fmt.Println("业务处室分办协程!" + strconv.Itoa(i))
  1060. }
  1061. }
  1062. }
  1063. lock.Unlock()
  1064. }
  1065. }
  1066. // @Title 业务处室提交评价审核
  1067. // @Description 业务处室提交评价审核
  1068. // @Success 200 {object} controllers.Request
  1069. // @router /business-submit-review/:id [post]
  1070. func (this *OilContractReviewController) BusinessSubmitEvaEntity() {
  1071. Id := this.Ctx.Input.Param(":id")
  1072. ProfessionalAudit := this.GetString("ProfessionalAudit")
  1073. AuditRemark := this.GetString("AuditRemark")
  1074. userId := this.User.Id
  1075. var baseUserInfo userRole.Base_User
  1076. userService := userRole.GetUserService(utils.DBE)
  1077. userService.GetEntityById(userId, &baseUserInfo)
  1078. unitId := baseUserInfo.UnitId
  1079. var errInfo ErrorDataInfo
  1080. defer func() { //finally处理失败的异常
  1081. if err := recover(); err != nil {
  1082. errInfo.Message = err.(string)
  1083. errInfo.Code = -1
  1084. this.Data["json"] = &errInfo
  1085. this.ServeJSON()
  1086. } else {
  1087. //返回正确结果
  1088. errInfo.Message = "审核提交成功,请耐心等待批处理结果"
  1089. errInfo.Code = 0
  1090. this.Data["json"] = &errInfo
  1091. this.ServeJSON()
  1092. }
  1093. }()
  1094. if ProfessionalAudit == "" {
  1095. errInfo.Message = "请选择审批人"
  1096. errInfo.Code = -1
  1097. this.Data["json"] = &errInfo
  1098. this.ServeJSON()
  1099. }
  1100. //取出日常评审主表信息
  1101. conRev := contractReview.GetOilContractReviewService(utils.DBE)
  1102. var contractReviewEntity contractReview.OilContractReview
  1103. conRev.GetEntityById(Id, &contractReviewEntity)
  1104. //取出合同表
  1105. contractSvc := contract.GetOilContractService(utils.DBE)
  1106. var contractEntity contract.OilContract
  1107. contractSvc.GetEntityById(contractReviewEntity.ContractId, &contractEntity)
  1108. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1109. //启动工作流
  1110. businessKey := contractReviewEntity.BusinessKey
  1111. processInstanceId := contractReviewEntity.WorkflowId
  1112. // 如果被驳回,不再新启工作流
  1113. if processInstanceId == "" {
  1114. //启动工作流
  1115. businessKey = Id + "-" + strconv.Itoa(contractReviewEntity.AuditIndex)
  1116. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS, businessKey, this.User.Id, "1", contractEntity.ContractClass, contractEntity.SupplierName)
  1117. if len(processInstanceId) <= 0 {
  1118. panic("工作流启动失败!")
  1119. }
  1120. contractReviewEntity.AuditIndex += 1
  1121. }
  1122. // 将启动和工作流,选择的初审和复审人员保存下来
  1123. cols := []string{
  1124. "Id",
  1125. "WorkflowId",
  1126. "BusinessKey",
  1127. "ProcessKey",
  1128. "CommitComId",
  1129. "AuditIndex",
  1130. "ProfessionalAudit",
  1131. }
  1132. contractReviewEntity.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS
  1133. contractReviewEntity.BusinessKey = businessKey
  1134. contractReviewEntity.WorkflowId = processInstanceId
  1135. contractReviewEntity.CommitComId = strconv.Itoa(unitId)
  1136. contractReviewEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
  1137. conRev.UpdateEntityByIdCols(Id, contractReviewEntity, cols)
  1138. var ActiComplete workflow.ActiCompleteVM
  1139. ActiComplete.ProcessKey = workflow.OIL_DAILY_CONTRACT_EVA_BY_BUSINESS
  1140. ActiComplete.BusinessKey = contractReviewEntity.BusinessKey
  1141. ActiComplete.UserId = this.User.Id // 当前审批操作人员
  1142. ActiComplete.Result = "1" //业务处室分办提交给处室审核
  1143. ActiComplete.UserNames = ProfessionalAudit
  1144. ActiComplete.Remarks = AuditRemark
  1145. ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
  1146. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1147. if receiveVal != "true" {
  1148. panic("工作流异常,请联系管理员!" + receiveVal)
  1149. }
  1150. }