suppliercert.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/paymentinfo"
  4. "encoding/json"
  5. "fmt"
  6. "strconv"
  7. "strings"
  8. "time"
  9. "dashoo.cn/backend/api/business/auditsetting"
  10. "dashoo.cn/backend/api/business/workflow"
  11. "dashoo.cn/backend/api/business/baseUser"
  12. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  13. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  14. . "dashoo.cn/backend/api/controllers"
  15. "dashoo.cn/business2/userRole"
  16. "dashoo.cn/utils"
  17. )
  18. type OilSupplierCertController struct {
  19. BaseController
  20. }
  21. // @Title 获取列表
  22. // @Description get user by token
  23. // @Success 200 {object} []suppliercert.OilSupplierCert
  24. // @router /list [get]
  25. func (this *OilSupplierCertController) GetEntityList() {
  26. //获取分页信息
  27. page := this.GetPageInfoForm()
  28. where := " 1=1 "
  29. orderby := "Id"
  30. asc := false
  31. Order := this.GetString("Order")
  32. Prop := this.GetString("Prop")
  33. if Order != "" && Prop != "" {
  34. orderby = Prop
  35. if Order == "asc" {
  36. asc = true
  37. }
  38. }
  39. Id := this.GetString("Id")
  40. SupplierId := this.GetString("SupplierId")
  41. AccessCardNo := this.GetString("AccessCardNo")
  42. SupplierTypeCode := this.GetString("SupplierTypeCode")
  43. SupplierTypeName := this.GetString("SupplierTypeName")
  44. RecUnitReason := this.GetString("RecUnitReason")
  45. RecUnitPerson := this.GetString("RecUnitPerson")
  46. RecDate := this.GetString("RecDate")
  47. RecUnitId := this.GetString("RecUnitId")
  48. RecUnitName := this.GetString("RecUnitName")
  49. StatusA := this.GetString("StatusA")
  50. BackReason := this.GetString("BackReason")
  51. InFlag := this.GetString("InFlag")
  52. EffectStartTime := this.GetString("EffectStartTime")
  53. EffectEndTime := this.GetString("EffectEndTime")
  54. AuditProcessNote := this.GetString("AuditProcessNote")
  55. AuditDate := this.GetString("AuditDate")
  56. PayNotice := this.GetString("PayNotice")
  57. SupplierStatus := this.GetString("SupplierStatus")
  58. MgrType := this.GetString("MgrType")
  59. Type := this.GetString("Type")
  60. MgrUnit := this.GetString("MgrUnit")
  61. AddinTime := this.GetString("AddinTime")
  62. EffectTime := this.GetString("EffectTime")
  63. ApplyTime := this.GetString("ApplyTime")
  64. SupplierNo := this.GetString("SupplierNo")
  65. MDMFlag := this.GetString("MDMFlag")
  66. InternalFlag := this.GetString("InternalFlag")
  67. ImportFlag := this.GetString("ImportFlag")
  68. OutsideFlog := this.GetString("OutsideFlog")
  69. Remark := this.GetString("Remark")
  70. IsDelete := this.GetString("IsDelete")
  71. CreateOn := this.GetString("CreateOn")
  72. CreateUserId := this.GetString("CreateUserId")
  73. CreateBy := this.GetString("CreateBy")
  74. ModifiedOn := this.GetString("ModifiedOn")
  75. ModifiedUserId := this.GetString("ModifiedUserId")
  76. ModifiedBy := this.GetString("ModifiedBy")
  77. if Id != "" {
  78. where = where + " and Id like '%" + Id + "%'"
  79. }
  80. if SupplierId != "" {
  81. where = where + " and SupplierId like '%" + SupplierId + "%'"
  82. }
  83. if AccessCardNo != "" {
  84. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  85. }
  86. if SupplierTypeCode != "" {
  87. where = where + " and SupplierTypeCode like '%" + SupplierTypeCode + "%'"
  88. }
  89. if SupplierTypeName != "" {
  90. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  91. }
  92. if RecUnitReason != "" {
  93. where = where + " and RecUnitReason like '%" + RecUnitReason + "%'"
  94. }
  95. if RecUnitPerson != "" {
  96. where = where + " and RecUnitPerson like '%" + RecUnitPerson + "%'"
  97. }
  98. if RecDate != "" {
  99. where = where + " and RecDate like '%" + RecDate + "%'"
  100. }
  101. if RecUnitId != "" {
  102. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  103. }
  104. if RecUnitName != "" {
  105. where = where + " and RecUnitName like '%" + RecUnitName + "%'"
  106. }
  107. if StatusA != "" {
  108. where = where + " and StatusA like '%" + StatusA + "%'"
  109. }
  110. if BackReason != "" {
  111. where = where + " and BackReason like '%" + BackReason + "%'"
  112. }
  113. if InFlag != "" {
  114. where = where + " and InFlag like '%" + InFlag + "%'"
  115. }
  116. if EffectStartTime != "" {
  117. where = where + " and EffectStartTime like '%" + EffectStartTime + "%'"
  118. }
  119. if EffectEndTime != "" {
  120. where = where + " and EffectEndTime like '%" + EffectEndTime + "%'"
  121. }
  122. if AuditProcessNote != "" {
  123. where = where + " and AuditProcessNote like '%" + AuditProcessNote + "%'"
  124. }
  125. if AuditDate != "" {
  126. where = where + " and AuditDate like '%" + AuditDate + "%'"
  127. }
  128. if PayNotice != "" {
  129. where = where + " and PayNotice like '%" + PayNotice + "%'"
  130. }
  131. if SupplierStatus != "" {
  132. where = where + " and SupplierStatus like '%" + SupplierStatus + "%'"
  133. }
  134. if MgrType != "" {
  135. where = where + " and MgrType like '%" + MgrType + "%'"
  136. }
  137. if Type != "" {
  138. where = where + " and Type like '%" + Type + "%'"
  139. }
  140. if MgrUnit != "" {
  141. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  142. }
  143. if AddinTime != "" {
  144. where = where + " and AddinTime like '%" + AddinTime + "%'"
  145. }
  146. if EffectTime != "" {
  147. where = where + " and EffectTime like '%" + EffectTime + "%'"
  148. }
  149. if ApplyTime != "" {
  150. where = where + " and ApplyTime like '%" + ApplyTime + "%'"
  151. }
  152. if SupplierNo != "" {
  153. where = where + " and SupplierNo like '%" + SupplierNo + "%'"
  154. }
  155. if MDMFlag != "" {
  156. where = where + " and MDMFlag like '%" + MDMFlag + "%'"
  157. }
  158. if InternalFlag != "" {
  159. where = where + " and InternalFlag like '%" + InternalFlag + "%'"
  160. }
  161. if ImportFlag != "" {
  162. where = where + " and ImportFlag like '%" + ImportFlag + "%'"
  163. }
  164. if OutsideFlog != "" {
  165. where = where + " and OutsideFlog like '%" + OutsideFlog + "%'"
  166. }
  167. if Remark != "" {
  168. where = where + " and Remark like '%" + Remark + "%'"
  169. }
  170. if IsDelete != "" {
  171. where = where + " and IsDelete like '%" + IsDelete + "%'"
  172. }
  173. if CreateOn != "" {
  174. where = where + " and CreateOn like '%" + CreateOn + "%'"
  175. }
  176. if CreateUserId != "" {
  177. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  178. }
  179. if CreateBy != "" {
  180. where = where + " and CreateBy like '%" + CreateBy + "%'"
  181. }
  182. if ModifiedOn != "" {
  183. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  184. }
  185. if ModifiedUserId != "" {
  186. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  187. }
  188. if ModifiedBy != "" {
  189. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  190. }
  191. if CreateOn != "" {
  192. dates := strings.Split(CreateOn, ",")
  193. if len(dates) == 2 {
  194. minDate := dates[0]
  195. maxDate := dates[1]
  196. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  197. }
  198. }
  199. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  200. var list []suppliercert.OilSupplierCert
  201. total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
  202. var datainfo DataInfo
  203. datainfo.Items = list
  204. datainfo.CurrentItemCount = total
  205. datainfo.PageIndex = page.CurrentPage
  206. datainfo.ItemsPerPage = page.Size
  207. this.Data["json"] = &datainfo
  208. this.ServeJSON()
  209. }
  210. // @Title 获取字典列表
  211. // @Description get user by token
  212. // @Success 200 {object} map[string]interface{}
  213. // @router /dictlist [get]
  214. func (this *OilSupplierCertController) GetDictList() {
  215. dictList := make(map[string]interface{})
  216. //dictSvc := items.GetItemsService(utils.DBE)
  217. userSvc := baseUser.GetBaseUserService(utils.DBE)
  218. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  219. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
  220. var userEntity userRole.Base_User
  221. userSvc.GetEntityById(this.User.Id, &userEntity)
  222. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  223. //var dictCustomer []svccustomer.Customer
  224. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  225. //dictList["EntrustCorp"] = &dictCustomer
  226. var datainfo DataInfo
  227. datainfo.Items = dictList
  228. this.Data["json"] = &datainfo
  229. this.ServeJSON()
  230. }
  231. // @Title 获取实体
  232. // @Description 获取实体
  233. // @Success 200 {object} suppliercert.OilSupplierCert
  234. // @router /get/:id [get]
  235. func (this *OilSupplierCertController) GetEntity() {
  236. Id := this.Ctx.Input.Param(":id")
  237. var model suppliercert.OilSupplierCert
  238. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  239. svc.GetEntityByIdBytbl(OilSupplierCertName, Id, &model)
  240. this.Data["json"] = &model
  241. this.ServeJSON()
  242. }
  243. // @Title 获取实体
  244. // @Description 获取实体
  245. // @Success 200 {object} suppliercert.OilSupplierCert
  246. // @router /getbycreatorandtype/:typecode [get]
  247. func (this *OilSupplierCertController) GetEntityByCreatorId() {
  248. creatorId := this.User.Id
  249. typeCode := this.Ctx.Input.Param(":typecode")
  250. var model suppliercert.OilSupplierCert
  251. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  252. where := " CreateUserId = '" + creatorId + "'"
  253. where += " and SupplierTypeCode = '" + typeCode + "'"
  254. svc.GetEntityByWhere(OilSupplierCertName, where, &model)
  255. this.Data["json"] = &model
  256. this.ServeJSON()
  257. }
  258. // @Title 添加
  259. // @Description 新增
  260. // @Success 200 {object} controllers.Request
  261. // @router /add [post]
  262. func (this *OilSupplierCertController) AddEntity() {
  263. var model suppliercert.OilSupplierCert
  264. var jsonBlob = this.Ctx.Input.RequestBody
  265. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  266. json.Unmarshal(jsonBlob, &model)
  267. model.CreateOn = time.Now()
  268. model.CreateBy = this.User.Realname
  269. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  270. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  271. _, err := svc.InsertEntityBytbl(OilSupplierCertName, &model)
  272. var errinfo ErrorDataInfo
  273. if err == nil {
  274. //新增
  275. errinfo.Message = "添加成功!"
  276. errinfo.Code = 0
  277. errinfo.Item = model.Id
  278. this.Data["json"] = &errinfo
  279. this.ServeJSON()
  280. } else {
  281. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  282. errinfo.Code = -1
  283. this.Data["json"] = &errinfo
  284. this.ServeJSON()
  285. }
  286. }
  287. // @Title 修改实体
  288. // @Description 修改实体
  289. // @Success 200 {object} controllers.Request
  290. // @router /update/:id [post]
  291. func (this *OilSupplierCertController) UpdateEntity() {
  292. id := this.Ctx.Input.Param(":id")
  293. var errinfo ErrorInfo
  294. if id == "" {
  295. errinfo.Message = "操作失败!请求信息不完整"
  296. errinfo.Code = -2
  297. this.Data["json"] = &errinfo
  298. this.ServeJSON()
  299. return
  300. }
  301. var model suppliercert.OilSupplierCert
  302. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  303. var jsonBlob = this.Ctx.Input.RequestBody
  304. json.Unmarshal(jsonBlob, &model)
  305. model.ModifiedOn = time.Now()
  306. model.ModifiedBy = this.User.Realname
  307. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  308. cols := []string{
  309. "Id",
  310. "SupplierId",
  311. "AccessCardNo",
  312. "SupplierTypeCode",
  313. "SupplierTypeName",
  314. "RecUnitReason",
  315. "RecUnitPerson",
  316. "RecDate",
  317. "RecUnitId",
  318. "RecUnitName",
  319. "Status",
  320. "BackReason",
  321. "InFlag",
  322. "EffectStartTime",
  323. "EffectEndTime",
  324. "AuditProcessNote",
  325. "AuditDate",
  326. "PayNotice",
  327. "SupplierStatus",
  328. "MgrType",
  329. "Type",
  330. "MgrUnit",
  331. "AddinTime",
  332. "EffectTime",
  333. "ApplyTime",
  334. "SupplierNo",
  335. "MDMFlag",
  336. "InternalFlag",
  337. "ImportFlag",
  338. "OutsideFlog",
  339. "Remark",
  340. "IsDelete",
  341. "CreateOn",
  342. "CreateUserId",
  343. "CreateBy",
  344. "ModifiedOn",
  345. "ModifiedUserId",
  346. "ModifiedBy",
  347. }
  348. err := svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols)
  349. if err == nil {
  350. errinfo.Message = "修改成功!"
  351. errinfo.Code = 0
  352. this.Data["json"] = &errinfo
  353. this.ServeJSON()
  354. } else {
  355. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  356. errinfo.Code = -1
  357. this.Data["json"] = &errinfo
  358. this.ServeJSON()
  359. }
  360. }
  361. // @Title 删除单条信息
  362. // @Description
  363. // @Success 200 {object} ErrorInfo
  364. // @Failure 403 :id 为空
  365. // @router /delete/:Id [delete]
  366. func (this *OilSupplierCertController) DeleteEntity() {
  367. Id := this.Ctx.Input.Param(":Id")
  368. var errinfo ErrorInfo
  369. if Id == "" {
  370. errinfo.Message = "操作失败!请求信息不完整"
  371. errinfo.Code = -2
  372. this.Data["json"] = &errinfo
  373. this.ServeJSON()
  374. return
  375. }
  376. var model suppliercert.OilSupplierCert
  377. var entityempty suppliercert.OilSupplierCert
  378. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  379. opdesc := "删除-" + Id
  380. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  381. if err == nil {
  382. errinfo.Message = "删除成功"
  383. errinfo.Code = 0
  384. this.Data["json"] = &errinfo
  385. this.ServeJSON()
  386. } else {
  387. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  388. errinfo.Code = -1
  389. this.Data["json"] = &errinfo
  390. this.ServeJSON()
  391. }
  392. }
  393. // @Title 提交审批
  394. // @Description 提交审批
  395. // @Success 200 {object} controllers.Request
  396. // @router /audit/:id [post]
  397. func (this *OilSupplierCertController) AuditEntity() {
  398. certId := this.Ctx.Input.Param(":id")
  399. firstAudit := this.GetString("firstAudit")
  400. //取出审批列表
  401. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  402. var supplierCertEntity suppliercert.OilSupplierCert
  403. certSrv.GetEntityById(certId, &supplierCertEntity)
  404. var errinfo ErrorDataInfo
  405. defer func() { //finally处理失败的异常
  406. if err := recover(); err != nil {
  407. errinfo.Message = "提交失败," + err.(string)
  408. errinfo.Code = -1
  409. this.Data["json"] = &errinfo
  410. this.ServeJSON()
  411. } else {
  412. //返回正确结果
  413. errinfo.Message = "审核提交成功"
  414. errinfo.Code = 0
  415. this.Data["json"] = &errinfo
  416. this.ServeJSON()
  417. }
  418. }()
  419. ////判断当前部门是否企业用户
  420. //result := "1"
  421. //if this.User.IsCompanyUser == 1 {
  422. // result = "0"
  423. //}
  424. svcActiviti := workflow.GetActivitiService(utils.DBE)
  425. ////获得有审核权限的人员
  426. //var users []userRole.Base_RoleList
  427. //var userIds string
  428. //var auditWorkflow auditsetting.Base_OilAuditSetting
  429. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  430. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, firstAudit, workflow.FIRST_TRIAL, &auditWorkflow)
  431. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  432. processInstanceId := ""
  433. if supplierCertEntity.WorkflowId == "0" || len(supplierCertEntity.WorkflowId) <= 0 {
  434. //启动工作流
  435. processInstanceId = svcActiviti.StartProcess(workflow.OIL_SUPPLIER_APPLY, certId, this.User.Id)
  436. }
  437. //processInstanceId,_ := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.FIRST_TRIAL, this.User.Id, result, "提交给二级单位初审", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  438. //for _, tmpUser := range users {
  439. // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  440. //}
  441. //userIds = strings.Trim(userIds, ",")
  442. var ActiComplete workflow.ActiCompleteVM
  443. ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
  444. ActiComplete.BusinessKey = certId
  445. ActiComplete.UserNames = firstAudit
  446. ActiComplete.UserId = this.User.Id
  447. ActiComplete.Result = "1"
  448. ActiComplete.Remarks = ""
  449. ActiComplete.CallbackUrl = ""
  450. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  451. if receiveVal == "true" {
  452. errinfo.Message = "提交成功!"
  453. errinfo.Code = 0
  454. this.Data["json"] = &errinfo
  455. this.ServeJSON()
  456. } else {
  457. errinfo.Message = "工作流异常,请联系管理员!"
  458. errinfo.Code = -1
  459. this.Data["json"] = &errinfo
  460. this.ServeJSON()
  461. return
  462. }
  463. fmt.Println("-----------processInstanceId------------")
  464. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  465. supplierCertEntity.WorkflowId = processInstanceId
  466. supplierCertEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  467. supplierCertEntity.Step = 2
  468. supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  469. cols := []string{
  470. "Id",
  471. "WorkflowId",
  472. "Status",
  473. "Step",
  474. "FirstAudit",
  475. }
  476. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  477. //var model classorgsetting.OilClassOrgSetting
  478. //var jsonBlob = this.Ctx.Input.RequestBody
  479. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  480. //
  481. //json.Unmarshal(jsonBlob, &model)
  482. //model.CreateOn = time.Now()
  483. //model.CreateBy = this.User.Realname
  484. //model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  485. ////model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  486. //
  487. //svc.InsertEntityBytbl(OilSupplierCertName, &model)
  488. //fmt.Println(model)
  489. }
  490. // @Title 专业审批
  491. // @Description 准入初审提交审批
  492. // @Success 200 {object} controllers.Request
  493. // @router /admission/:id [post]
  494. func (this *OilSupplierCertController) AuditEntityadmission() {
  495. certId := this.Ctx.Input.Param(":id")
  496. var errinfo ErrorDataInfo
  497. defer func() { //finally处理失败的异常
  498. if err := recover(); err != nil {
  499. errinfo.Message = "提交失败," + err.(string)
  500. errinfo.Code = -1
  501. this.Data["json"] = &errinfo
  502. this.ServeJSON()
  503. } else {
  504. //返回正确结果
  505. errinfo.Message = "审核提交成功"
  506. errinfo.Code = 0
  507. this.Data["json"] = &errinfo
  508. this.ServeJSON()
  509. }
  510. }()
  511. //取出审批列表
  512. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  513. certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.PROF_AUDIT, this.User.Id, "1", "提交给专业科室审核", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  514. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  515. var supplierCertEntity suppliercert.OilSupplierCert
  516. certSrv.GetEntityById(certId, supplierCertEntity)
  517. supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //二级单位初审
  518. cols := []string{
  519. "Id",
  520. "Status",
  521. }
  522. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  523. }
  524. // @Title 增项审批
  525. // @Description 提交审批
  526. // @Success 200 {object} controllers.Request
  527. // @router /auditappend/:id [post]
  528. func (this *OilSupplierCertController) AuditEntityappend() {
  529. certId := this.Ctx.Input.Param(":id")
  530. var errinfo ErrorDataInfo
  531. defer func() { //finally处理失败的异常
  532. if err := recover(); err != nil {
  533. errinfo.Message = "提交失败," + err.(string)
  534. errinfo.Code = -1
  535. this.Data["json"] = &errinfo
  536. this.ServeJSON()
  537. } else {
  538. //返回正确结果
  539. errinfo.Message = "审核提交成功"
  540. errinfo.Code = 0
  541. this.Data["json"] = &errinfo
  542. this.ServeJSON()
  543. }
  544. }()
  545. var IsCompanyU string
  546. if this.User.IsCompanyUser == 1 {
  547. IsCompanyU = "0"
  548. } else if this.User.IsCompanyUser == 0 {
  549. IsCompanyU = "1"
  550. }
  551. //取出审批列表
  552. certSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  553. processInstanceId := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPEND, workflow.FIRST_TRIAL, this.User.Id, IsCompanyU, "提交增项初审", OilSupplierCertAppendSubName, OilClassOrgSettingName)
  554. fmt.Println("--------processInstanceId--------", processInstanceId)
  555. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  556. var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend
  557. certSrv.GetEntityById(certId, supplierCertAppendEntity)
  558. supplierCertAppendEntity.WorkFlowId = processInstanceId + ""
  559. supplierCertAppendEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  560. cols := []string{
  561. "Id",
  562. "WorkflowId",
  563. "Status",
  564. }
  565. certSrv.UpdateEntityByIdCols(certId, supplierCertAppendEntity, cols)
  566. }
  567. // @Title 审批
  568. // @Description 审批
  569. // @Param body body suppliercert.OilSupplierCert
  570. // @Success 200 {object} controllers.Request
  571. // @router /auditEntityFir/:id [post]
  572. func (this *OilSupplierCertController) AuditEntityFir() {
  573. certId := this.Ctx.Input.Param(":id")
  574. auditer := this.GetString("auditer")
  575. majorDept := this.GetString("majorDept")
  576. //取出审批列表
  577. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  578. var supplierCertEntity suppliercert.OilSupplierCert
  579. certSrv.GetEntityById(certId, &supplierCertEntity)
  580. var jsonblob = this.Ctx.Input.RequestBody
  581. var dataother ShenHeModel
  582. json.Unmarshal(jsonblob, &dataother)
  583. var errinfo ErrorDataInfo
  584. defer func() { //finally处理失败的异常
  585. if err := recover(); err != nil {
  586. errinfo.Message = "提交失败," + err.(string)
  587. errinfo.Code = -1
  588. this.Data["json"] = &errinfo
  589. this.ServeJSON()
  590. } else {
  591. //返回正确结果
  592. errinfo.Message = "审核提交成功"
  593. errinfo.Code = 0
  594. this.Data["json"] = &errinfo
  595. this.ServeJSON()
  596. }
  597. }()
  598. //remarks := ""
  599. step := 2
  600. status := ""
  601. var userIds string
  602. if supplierCertEntity.Status == "1" {
  603. userIds = auditer
  604. status = suppliercert.SECOND_TRIAL_STATUS
  605. step = 2
  606. supplierCertEntity.ThirdAudit,_ = strconv.Atoi(majorDept)
  607. cols := []string{
  608. "ThirdAudit",
  609. }
  610. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  611. } else if supplierCertEntity.Status == "2" {
  612. status = suppliercert.THIRD_TRIAL_STATUS
  613. step = 2
  614. //获得有专业审核接收权限的人员
  615. //var users1 []userRole.Base_RoleList
  616. //var auditWorkflow1 auditsetting.Base_OilAuditSetting
  617. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  618. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &auditWorkflow1)
  619. //users1 = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow1.RoleId), this.User.AccCode)
  620. var users []suppliercert.UserList
  621. where := "OrganizeId=" + strconv.Itoa(supplierCertEntity.ThirdAudit) + " and AuditStepCode='" + workflow.PROF_RECE + "'"
  622. certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
  623. for _, tmpUser := range users {
  624. userIds += strconv.FormatInt(tmpUser.UserId, 10) + ","
  625. }
  626. userIds = strings.Trim(userIds, ",")
  627. } else if supplierCertEntity.Status == "3" {
  628. userIds = auditer
  629. status = suppliercert.PROF_AUDIT_STATUS
  630. step = 2
  631. } else if supplierCertEntity.Status == "4" {
  632. status = suppliercert.CENT_AUDIT_STATUS
  633. step = 2
  634. ////获得有专业审核接收权限的人员
  635. //var users1 []userRole.Base_RoleList
  636. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  637. //users1 = rsvc.GetUserByRole("10000204", this.User.AccCode)
  638. var users []suppliercert.UserList
  639. where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
  640. certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
  641. for _, tmpUser := range users {
  642. userIds += strconv.FormatInt(tmpUser.UserId, 10) + ","
  643. }
  644. userIds = strings.Trim(userIds, ",")
  645. } else if supplierCertEntity.Status == "5" {
  646. userIds = auditer
  647. status = suppliercert.PAYING_AUDIT_STATUS
  648. step = 3
  649. }
  650. svcActiviti := workflow.GetActivitiService(utils.DBE)
  651. var ActiComplete workflow.ActiCompleteVM
  652. ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
  653. ActiComplete.BusinessKey = certId
  654. ActiComplete.UserNames = userIds
  655. ActiComplete.UserId = this.User.Id
  656. ActiComplete.Remarks = dataother.AuditorRemark
  657. ActiComplete.CallbackUrl = ""
  658. if dataother.SuccessStatus == 1 {
  659. ActiComplete.Result = "1"
  660. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  661. if receiveVal == "true" {
  662. supplierCertEntity.Status = status
  663. supplierCertEntity.Step = step
  664. cols := []string{
  665. "Status",
  666. "Step",
  667. }
  668. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  669. if supplierCertEntity.Status == "5" {
  670. paysvc := paymentinfo.GetPaymentService(utils.DBE)
  671. var Amount float64
  672. if supplierCertEntity.SupplierTypeCode == "01" {
  673. Amount = 6000
  674. }else if supplierCertEntity.SupplierTypeCode == "02"{
  675. Amount = 7000
  676. }else if supplierCertEntity.SupplierTypeCode == "03" {
  677. Amount = 8000
  678. }
  679. paysvc.AddPaymentinfo(supplierCertEntity.SupplierId, supplierCertEntity.Id, Amount,"1")
  680. }
  681. errinfo.Message = "提交成功!"
  682. errinfo.Code = 0
  683. this.Data["json"] = &errinfo
  684. this.ServeJSON()
  685. } else {
  686. errinfo.Message = "工作流异常,请联系管理员!"
  687. errinfo.Code = -1
  688. this.Data["json"] = &errinfo
  689. this.ServeJSON()
  690. return
  691. }
  692. } else {
  693. ActiComplete.Result = "0"
  694. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  695. if receiveVal == "true" {
  696. supplierCertEntity.Status = "0"
  697. supplierCertEntity.Step = step
  698. cols := []string{
  699. "Status",
  700. "Step",
  701. }
  702. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  703. errinfo.Message = "提交成功!"
  704. errinfo.Code = 0
  705. this.Data["json"] = &errinfo
  706. this.ServeJSON()
  707. } else {
  708. errinfo.Message = "工作流异常,请联系管理员!"
  709. errinfo.Code = -1
  710. this.Data["json"] = &errinfo
  711. this.ServeJSON()
  712. return
  713. }
  714. }
  715. }
  716. // @Title 审核
  717. // @Description 审核
  718. // @Success 200 {object} controllers.Request
  719. // @router /auditcallback [get]
  720. func (this *OilSupplierCertController) AuditCallback() {
  721. id := this.GetString("Id")
  722. status := this.GetString("status")
  723. step := this.GetString("step")
  724. var supplierCertEntity suppliercert.OilSupplierCert
  725. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  726. supplierCertEntity.Status = status
  727. supplierCertEntity.Step, _ = strconv.Atoi(step)
  728. cols := []string{
  729. "Id",
  730. "Status",
  731. "step",
  732. }
  733. svc.UpdateEntityByIdCols(id, supplierCertEntity, cols)
  734. fmt.Println(id, status, step)
  735. }
  736. // @Title 获取实体
  737. // @Description 获取实体
  738. // @Success 200 {object} controllers.Request
  739. // @router /isaccess [get]
  740. func (this *OilSupplierCertController) IsAccess() {
  741. auditstepcode := this.GetString("auditstepcode")
  742. var users []userRole.Base_RoleList
  743. var auditWorkflow auditsetting.Base_OilAuditSetting
  744. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  745. res := false
  746. if auditstepcode == workflow.PROF_CONCENT { // 集中审批
  747. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.PROF_AUDIT, &auditWorkflow)
  748. users = rsvc.GetUserByRole("10000204", this.User.AccCode)
  749. for _, user := range users {
  750. if this.User.Id == strconv.Itoa(int(user.Id)) {
  751. res = true
  752. break
  753. }
  754. }
  755. } else {
  756. var users []suppliercert.UserList
  757. where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + auditstepcode + "'"
  758. rsvc.GetEntitysByWhere(OilAuditSettingName,where, &users)
  759. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, auditstepcode, &auditWorkflow)
  760. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode)
  761. for _, user := range users {
  762. if this.User.Id == strconv.Itoa(int(user.UserId)) {
  763. res = true
  764. break
  765. }
  766. }
  767. }
  768. this.Data["json"] = res
  769. this.ServeJSON()
  770. }