suppliercert.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  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("FirstAuditName")
  400. AuditRemark := this.GetString("AuditRemark")
  401. //取出审批列表
  402. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  403. var supplierCertEntity suppliercert.OilSupplierCert
  404. certSrv.GetEntityById(certId, &supplierCertEntity)
  405. var errinfo ErrorDataInfo
  406. defer func() { //finally处理失败的异常
  407. if err := recover(); err != nil {
  408. errinfo.Message = "提交失败," + err.(string)
  409. errinfo.Code = -1
  410. this.Data["json"] = &errinfo
  411. this.ServeJSON()
  412. } else {
  413. //返回正确结果
  414. errinfo.Message = "审核提交成功"
  415. errinfo.Code = 0
  416. this.Data["json"] = &errinfo
  417. this.ServeJSON()
  418. }
  419. }()
  420. ////判断当前部门是否企业用户
  421. //result := "1"
  422. //if this.User.IsCompanyUser == 1 {
  423. // result = "0"
  424. //}
  425. svcActiviti := workflow.GetActivitiService(utils.DBE)
  426. ////获得有审核权限的人员
  427. //var users []userRole.Base_RoleList
  428. //var userIds string
  429. //var auditWorkflow auditsetting.Base_OilAuditSetting
  430. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  431. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, firstAudit, workflow.FIRST_TRIAL, &auditWorkflow)
  432. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  433. processInstanceId := ""
  434. if supplierCertEntity.WorkflowId == "0" || len(supplierCertEntity.WorkflowId) <= 0 {
  435. //启动工作流
  436. processInstanceId = svcActiviti.StartProcess(workflow.OIL_SUPPLIER_APPLY, certId, this.User.Id)
  437. } else {
  438. processInstanceId = supplierCertEntity.WorkflowId
  439. }
  440. //processInstanceId,_ := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.FIRST_TRIAL, this.User.Id, result, "提交给二级单位初审", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  441. //for _, tmpUser := range users {
  442. // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  443. //}
  444. //userIds = strings.Trim(userIds, ",")
  445. var ActiComplete workflow.ActiCompleteVM
  446. ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
  447. ActiComplete.BusinessKey = certId
  448. ActiComplete.UserNames = firstAudit
  449. ActiComplete.UserId = this.User.Id
  450. ActiComplete.Result = "1"
  451. ActiComplete.Remarks = AuditRemark
  452. ActiComplete.CallbackUrl = ""
  453. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  454. if receiveVal == "true" {
  455. errinfo.Message = "提交成功!"
  456. errinfo.Code = 0
  457. this.Data["json"] = &errinfo
  458. this.ServeJSON()
  459. } else {
  460. errinfo.Message = "工作流异常,请联系管理员!"
  461. errinfo.Code = -1
  462. this.Data["json"] = &errinfo
  463. this.ServeJSON()
  464. return
  465. }
  466. fmt.Println("-----------processInstanceId------------")
  467. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  468. supplierCertEntity.WorkflowId = processInstanceId
  469. supplierCertEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  470. supplierCertEntity.Step = 2
  471. supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  472. cols := []string{
  473. "Id",
  474. "WorkflowId",
  475. "Status",
  476. "Step",
  477. "FirstAudit",
  478. }
  479. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  480. //var model classorgsetting.OilClassOrgSetting
  481. //var jsonBlob = this.Ctx.Input.RequestBody
  482. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  483. //
  484. //json.Unmarshal(jsonBlob, &model)
  485. //model.CreateOn = time.Now()
  486. //model.CreateBy = this.User.Realname
  487. //model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  488. ////model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  489. //
  490. //svc.InsertEntityBytbl(OilSupplierCertName, &model)
  491. //fmt.Println(model)
  492. }
  493. // @Title 专业审批
  494. // @Description 准入初审提交审批
  495. // @Success 200 {object} controllers.Request
  496. // @router /admission/:id [post]
  497. func (this *OilSupplierCertController) AuditEntityadmission() {
  498. certId := this.Ctx.Input.Param(":id")
  499. var errinfo ErrorDataInfo
  500. defer func() { //finally处理失败的异常
  501. if err := recover(); err != nil {
  502. errinfo.Message = "提交失败," + err.(string)
  503. errinfo.Code = -1
  504. this.Data["json"] = &errinfo
  505. this.ServeJSON()
  506. } else {
  507. //返回正确结果
  508. errinfo.Message = "审核提交成功"
  509. errinfo.Code = 0
  510. this.Data["json"] = &errinfo
  511. this.ServeJSON()
  512. }
  513. }()
  514. //取出审批列表
  515. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  516. certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.PROF_AUDIT, this.User.Id, "1", "提交给专业科室审核", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  517. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  518. var supplierCertEntity suppliercert.OilSupplierCert
  519. certSrv.GetEntityById(certId, supplierCertEntity)
  520. supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //二级单位初审
  521. cols := []string{
  522. "Id",
  523. "Status",
  524. }
  525. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  526. }
  527. // @Title 增项审批
  528. // @Description 提交审批
  529. // @Success 200 {object} controllers.Request
  530. // @router /auditappend/:id [post]
  531. func (this *OilSupplierCertController) AuditEntityappend() {
  532. certId := this.Ctx.Input.Param(":id")
  533. var errinfo ErrorDataInfo
  534. defer func() { //finally处理失败的异常
  535. if err := recover(); err != nil {
  536. errinfo.Message = "提交失败," + err.(string)
  537. errinfo.Code = -1
  538. this.Data["json"] = &errinfo
  539. this.ServeJSON()
  540. } else {
  541. //返回正确结果
  542. errinfo.Message = "审核提交成功"
  543. errinfo.Code = 0
  544. this.Data["json"] = &errinfo
  545. this.ServeJSON()
  546. }
  547. }()
  548. var IsCompanyU string
  549. if this.User.IsCompanyUser == 1 {
  550. IsCompanyU = "0"
  551. } else if this.User.IsCompanyUser == 0 {
  552. IsCompanyU = "1"
  553. }
  554. //取出审批列表
  555. certSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  556. processInstanceId := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPEND, workflow.FIRST_TRIAL, this.User.Id, IsCompanyU, "提交增项初审", OilSupplierCertAppendSubName, OilClassOrgSettingName)
  557. fmt.Println("--------processInstanceId--------", processInstanceId)
  558. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  559. var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend
  560. certSrv.GetEntityById(certId, supplierCertAppendEntity)
  561. supplierCertAppendEntity.WorkFlowId = processInstanceId + ""
  562. supplierCertAppendEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  563. cols := []string{
  564. "Id",
  565. "WorkflowId",
  566. "Status",
  567. }
  568. certSrv.UpdateEntityByIdCols(certId, supplierCertAppendEntity, cols)
  569. }
  570. // @Title 审批
  571. // @Description 审批
  572. // @Param body body suppliercert.OilSupplierCert
  573. // @Success 200 {object} controllers.Request
  574. // @router /auditEntityFir/:id [post]
  575. func (this *OilSupplierCertController) AuditEntityFir() {
  576. certId := this.Ctx.Input.Param(":id")
  577. auditer := this.GetString("auditer")
  578. majorDept := this.GetString("majorDept")
  579. //取出审批列表
  580. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  581. var supplierCertEntity suppliercert.OilSupplierCert
  582. certSrv.GetEntityById(certId, &supplierCertEntity)
  583. var jsonblob = this.Ctx.Input.RequestBody
  584. var dataother ShenHeModel
  585. json.Unmarshal(jsonblob, &dataother)
  586. var errinfo ErrorDataInfo
  587. defer func() { //finally处理失败的异常
  588. if err := recover(); err != nil {
  589. errinfo.Message = "提交失败," + err.(string)
  590. errinfo.Code = -1
  591. this.Data["json"] = &errinfo
  592. this.ServeJSON()
  593. } else {
  594. //返回正确结果
  595. errinfo.Message = "审核提交成功"
  596. errinfo.Code = 0
  597. this.Data["json"] = &errinfo
  598. this.ServeJSON()
  599. }
  600. }()
  601. //remarks := ""
  602. step := 2
  603. status := ""
  604. var userIds string
  605. if supplierCertEntity.Status == "1" {
  606. userIds = auditer
  607. status = suppliercert.SECOND_TRIAL_STATUS
  608. step = 2
  609. supplierCertEntity.ThirdAudit,_ = strconv.Atoi(majorDept)
  610. cols := []string{
  611. "ThirdAudit",
  612. }
  613. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  614. } else if supplierCertEntity.Status == "2" {
  615. status = suppliercert.THIRD_TRIAL_STATUS
  616. step = 2
  617. //获得有专业审核接收权限的人员
  618. //var users1 []userRole.Base_RoleList
  619. //var auditWorkflow1 auditsetting.Base_OilAuditSetting
  620. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  621. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &auditWorkflow1)
  622. //users1 = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow1.RoleId), this.User.AccCode)
  623. //var auditset []auditsetting.Base_OilAuditSetting
  624. //where := "OrganizeId=" + strconv.Itoa(supplierCertEntity.ThirdAudit) + " and AuditStepCode='" + workflow.PROF_RECE + "'"
  625. //certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
  626. var users []userRole.Base_RoleList
  627. certSrv.GetAuditUser(strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &users)
  628. for _, tmpUser := range users {
  629. userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  630. }
  631. userIds = strings.Trim(userIds, ",")
  632. } else if supplierCertEntity.Status == "3" {
  633. userIds = auditer
  634. status = suppliercert.PROF_AUDIT_STATUS
  635. step = 2
  636. } else if supplierCertEntity.Status == "4" {
  637. status = suppliercert.CENT_AUDIT_STATUS
  638. step = 2
  639. ////获得有专业审核接收权限的人员
  640. //var users1 []userRole.Base_RoleList
  641. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  642. //users1 = rsvc.GetUserByRole("10000204", this.User.AccCode)
  643. //var users []suppliercert.UserList
  644. //where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
  645. //certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
  646. var users []userRole.Base_RoleList
  647. certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
  648. for _, tmpUser := range users {
  649. userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  650. }
  651. userIds = strings.Trim(userIds, ",")
  652. } else if supplierCertEntity.Status == "5" {
  653. userIds = auditer
  654. status = suppliercert.PAYING_AUDIT_STATUS
  655. step = 3
  656. }
  657. svcActiviti := workflow.GetActivitiService(utils.DBE)
  658. var ActiComplete workflow.ActiCompleteVM
  659. ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
  660. ActiComplete.BusinessKey = certId
  661. ActiComplete.UserNames = userIds
  662. ActiComplete.UserId = this.User.Id
  663. ActiComplete.Remarks = dataother.AuditorRemark
  664. ActiComplete.CallbackUrl = ""
  665. if dataother.SuccessStatus == 1 {
  666. ActiComplete.Result = "1"
  667. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  668. if receiveVal == "true" {
  669. supplierCertEntity.Status = status
  670. supplierCertEntity.Step = step
  671. cols := []string{
  672. "Status",
  673. "Step",
  674. }
  675. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  676. if supplierCertEntity.Status == "5" {
  677. paysvc := paymentinfo.GetPaymentService(utils.DBE)
  678. var Amount float64
  679. if supplierCertEntity.SupplierTypeCode == "01" {
  680. Amount = 6000
  681. }else if supplierCertEntity.SupplierTypeCode == "02"{
  682. Amount = 7000
  683. }else if supplierCertEntity.SupplierTypeCode == "03" {
  684. Amount = 8000
  685. }
  686. paysvc.AddPaymentinfo(supplierCertEntity.SupplierId, supplierCertEntity.Id, Amount,"1")
  687. }
  688. errinfo.Message = "提交成功!"
  689. errinfo.Code = 0
  690. this.Data["json"] = &errinfo
  691. this.ServeJSON()
  692. } else {
  693. errinfo.Message = "工作流异常,请联系管理员!"
  694. errinfo.Code = -1
  695. this.Data["json"] = &errinfo
  696. this.ServeJSON()
  697. return
  698. }
  699. } else {
  700. ActiComplete.Result = "0"
  701. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  702. if receiveVal == "true" {
  703. supplierCertEntity.Status = "0"
  704. supplierCertEntity.Step = 1
  705. cols := []string{
  706. "Status",
  707. "Step",
  708. }
  709. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  710. errinfo.Message = "提交成功!"
  711. errinfo.Code = 0
  712. this.Data["json"] = &errinfo
  713. this.ServeJSON()
  714. } else {
  715. errinfo.Message = "工作流异常,请联系管理员!"
  716. errinfo.Code = -1
  717. this.Data["json"] = &errinfo
  718. this.ServeJSON()
  719. return
  720. }
  721. }
  722. }
  723. // @Title 审核
  724. // @Description 审核
  725. // @Success 200 {object} controllers.Request
  726. // @router /auditcallback [get]
  727. func (this *OilSupplierCertController) AuditCallback() {
  728. id := this.GetString("Id")
  729. status := this.GetString("status")
  730. step := this.GetString("step")
  731. var supplierCertEntity suppliercert.OilSupplierCert
  732. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  733. supplierCertEntity.Status = status
  734. supplierCertEntity.Step, _ = strconv.Atoi(step)
  735. cols := []string{
  736. "Id",
  737. "Status",
  738. "step",
  739. }
  740. svc.UpdateEntityByIdCols(id, supplierCertEntity, cols)
  741. fmt.Println(id, status, step)
  742. }
  743. // @Title 获取实体
  744. // @Description 获取实体
  745. // @Success 200 {object} controllers.Request
  746. // @router /isaccess [get]
  747. func (this *OilSupplierCertController) IsAccess() {
  748. auditstepcode := this.GetString("auditstepcode")
  749. var users []userRole.Base_RoleList
  750. var auditWorkflow auditsetting.Base_OilAuditSetting
  751. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  752. res := false
  753. if auditstepcode == workflow.PROF_CONCENT { // 集中审批
  754. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.PROF_AUDIT, &auditWorkflow)
  755. users = rsvc.GetUserByRole("10000204", this.User.AccCode)
  756. for _, user := range users {
  757. if this.User.Id == strconv.Itoa(int(user.Id)) {
  758. res = true
  759. break
  760. }
  761. }
  762. } else {
  763. //var users []suppliercert.UserList
  764. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + auditstepcode + "'"
  765. //rsvc.GetEntitysByWhere(OilAuditSettingName,where, &users)
  766. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, auditstepcode, &auditWorkflow)
  767. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode)
  768. var users []userRole.Base_RoleList
  769. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  770. certSrv.GetAuditUser(this.User.DepartmentId, auditstepcode, &users)
  771. for _, user := range users {
  772. if this.User.Id == strconv.Itoa(int(user.Id)) {
  773. res = true
  774. break
  775. }
  776. }
  777. }
  778. this.Data["json"] = res
  779. this.ServeJSON()
  780. }