infochange.go 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/audithistory"
  4. "dashoo.cn/backend/api/business/auditsetting"
  5. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  7. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  8. "dashoo.cn/business2/items"
  9. "dashoo.cn/business2/permission"
  10. "dashoo.cn/business2/userRole"
  11. "encoding/json"
  12. "fmt"
  13. "reflect"
  14. "strconv"
  15. "strings"
  16. "time"
  17. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  18. "dashoo.cn/backend/api/business/workflow"
  19. . "dashoo.cn/backend/api/controllers"
  20. "dashoo.cn/utils"
  21. )
  22. type InfoChangeController struct {
  23. BaseController
  24. }
  25. type InfoShenHeModel struct {
  26. InfoId int
  27. SuccessStatus int
  28. AuditorRemark string
  29. SuppId int
  30. }
  31. type InfoChangeItemsAll struct {
  32. InfochangeForm []infoitems
  33. SupplierId string
  34. MInfoId string
  35. }
  36. type infoitems struct {
  37. SelectItem string
  38. BeChangeInfo string
  39. ChangeInfo string
  40. }
  41. // @Title 获取实体
  42. // @Description 获取实体
  43. // @Success 200 {object} annualaudit.OilAnnualAudit
  44. // @router /get/:id [get]
  45. func (this *InfoChangeController) GetEntity() {
  46. CertId := this.Ctx.Input.Param(":id")
  47. var model []infochange.OilInfoChangeItem
  48. svc := infochange.GetInfoChangeService(utils.DBE)
  49. where := " SupplierId = " + CertId
  50. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
  51. var datainfo DataInfo
  52. datainfo.Items = model
  53. this.Data["json"] = &datainfo
  54. this.ServeJSON()
  55. }
  56. // @Title 获取实体
  57. // @Description 获取实体
  58. // @Success 200 {object} annualaudit.OilAnnualAudit
  59. // @router /auditget/:id [get]
  60. func (this *InfoChangeController) GetEntityThen() {
  61. InfoId := this.Ctx.Input.Param(":id")
  62. var model []infochange.OilInfoChangeItem
  63. svc := infochange.GetInfoChangeService(utils.DBE)
  64. where := " InfoId = " + InfoId + " and ChangeStatus = 0"
  65. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
  66. var datainfo DataInfo
  67. datainfo.Items = model
  68. this.Data["json"] = &datainfo
  69. this.ServeJSON()
  70. }
  71. // @Title 获取列表
  72. // @Description get user by token
  73. // @Success 200 {object} []supplier.OilSupplier
  74. // @router /supplist [get]
  75. func (this *InfoChangeController) GetSuppList() {
  76. //获取分页信息
  77. page := this.GetPageInfoForm()
  78. where := " 1=1 "
  79. orderby := "Id"
  80. asc := false
  81. Order := this.GetString("Order")
  82. Prop := this.GetString("Prop")
  83. if Order != "" && Prop != "" {
  84. orderby = Prop
  85. if Order == "asc" {
  86. asc = true
  87. }
  88. }
  89. SupplierName := this.GetString("SupplierName")
  90. OilCertificateNo := this.GetString("OilCertificateNo")
  91. Grade := this.GetString("Grade")
  92. MgrUnit := this.GetString("MgrUnit")
  93. OperType := this.GetString("OperType")
  94. Country := this.GetString("Country")
  95. MaunAgent := this.GetString("MaunAgent")
  96. ConstructTeam := this.GetString("ConstructTeam")
  97. CommercialNo := this.GetString("CommercialNo")
  98. OrganCode := this.GetString("OrganCode")
  99. CountryTaxNo := this.GetString("CountryTaxNo")
  100. LocalTaxNo := this.GetString("LocalTaxNo")
  101. Address := this.GetString("Address")
  102. Province := this.GetString("Province")
  103. City := this.GetString("City")
  104. Street := this.GetString("Street")
  105. HouseNo := this.GetString("HouseNo")
  106. ZipCode := this.GetString("ZipCode")
  107. QualitySystemCert := this.GetString("QualitySystemCert")
  108. ProductQualityCert := this.GetString("ProductQualityCert")
  109. MaunLicense := this.GetString("MaunLicense")
  110. QualifCert := this.GetString("QualifCert")
  111. QualifCertLevel := this.GetString("QualifCertLevel")
  112. SafetyLicense := this.GetString("SafetyLicense")
  113. TechServiceLic := this.GetString("TechServiceLic")
  114. TJInNotify := this.GetString("TJInNotify")
  115. SpecIndustryCert := this.GetString("SpecIndustryCert")
  116. LegalPerson := this.GetString("LegalPerson")
  117. CategoryCode := this.GetString("CategoryCode")
  118. CategoryName := this.GetString("CategoryName")
  119. RegCapital := this.GetString("RegCapital")
  120. Currency := this.GetString("Currency")
  121. ContactName := this.GetString("ContactName")
  122. CompanyType := this.GetString("CompanyType")
  123. SetupTime := this.GetString("SetupTime")
  124. DepositBank := this.GetString("DepositBank")
  125. BankAccount := this.GetString("BankAccount")
  126. EMail := this.GetString("EMail")
  127. BankCreditRating := this.GetString("BankCreditRating")
  128. Mobile := this.GetString("Mobile")
  129. Telphone := this.GetString("Telphone")
  130. Fax := this.GetString("Fax")
  131. CompanyTel := this.GetString("CompanyTel")
  132. QQ := this.GetString("QQ")
  133. CompanyUrl := this.GetString("CompanyUrl")
  134. SpecSupplier := this.GetString("SpecSupplier")
  135. SpecTypeCode := this.GetString("SpecTypeCode")
  136. SpecTypeName := this.GetString("SpecTypeName")
  137. Remark := this.GetString("Remark")
  138. CreateOn := this.GetString("CreateOn")
  139. if SupplierName != "" {
  140. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  141. }
  142. if OilCertificateNo != "" {
  143. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  144. }
  145. if Grade != "" {
  146. where = where + " and a.Grade like '%" + Grade + "%'"
  147. }
  148. if MgrUnit != "" {
  149. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  150. }
  151. if OperType != "" {
  152. where = where + " and a.OperType like '%" + OperType + "%'"
  153. }
  154. if Country != "" {
  155. where = where + " and a.Country like '%" + Country + "%'"
  156. }
  157. if MaunAgent != "" {
  158. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  159. }
  160. if ConstructTeam != "" {
  161. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  162. }
  163. if CommercialNo != "" {
  164. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  165. }
  166. if OrganCode != "" {
  167. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  168. }
  169. if CountryTaxNo != "" {
  170. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  171. }
  172. if LocalTaxNo != "" {
  173. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  174. }
  175. if Address != "" {
  176. where = where + " and a.Address like '%" + Address + "%'"
  177. }
  178. if Province != "" {
  179. where = where + " and a.Province like '%" + Province + "%'"
  180. }
  181. if City != "" {
  182. where = where + " and a.City like '%" + City + "%'"
  183. }
  184. if Street != "" {
  185. where = where + " and a.Street like '%" + Street + "%'"
  186. }
  187. if HouseNo != "" {
  188. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  189. }
  190. if ZipCode != "" {
  191. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  192. }
  193. if QualitySystemCert != "" {
  194. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  195. }
  196. if ProductQualityCert != "" {
  197. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  198. }
  199. if MaunLicense != "" {
  200. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  201. }
  202. if QualifCert != "" {
  203. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  204. }
  205. if QualifCertLevel != "" {
  206. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  207. }
  208. if SafetyLicense != "" {
  209. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  210. }
  211. if TechServiceLic != "" {
  212. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  213. }
  214. if TJInNotify != "" {
  215. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  216. }
  217. if SpecIndustryCert != "" {
  218. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  219. }
  220. if LegalPerson != "" {
  221. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  222. }
  223. if CategoryCode != "" {
  224. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  225. }
  226. if CategoryName != "" {
  227. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  228. }
  229. if RegCapital != "" {
  230. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  231. }
  232. if Currency != "" {
  233. where = where + " and a.Currency like '%" + Currency + "%'"
  234. }
  235. if ContactName != "" {
  236. where = where + " and a.ContactName like '%" + ContactName + "%'"
  237. }
  238. if CompanyType != "" {
  239. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  240. }
  241. if SetupTime != "" {
  242. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  243. }
  244. if DepositBank != "" {
  245. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  246. }
  247. if BankAccount != "" {
  248. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  249. }
  250. if EMail != "" {
  251. where = where + " and a.EMail like '%" + EMail + "%'"
  252. }
  253. if BankCreditRating != "" {
  254. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  255. }
  256. if Mobile != "" {
  257. where = where + " and a.Mobile like '%" + Mobile + "%'"
  258. }
  259. if Telphone != "" {
  260. where = where + " and a.Telphone like '%" + Telphone + "%'"
  261. }
  262. if Fax != "" {
  263. where = where + " and a.Fax like '%" + Fax + "%'"
  264. }
  265. if CompanyTel != "" {
  266. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  267. }
  268. if QQ != "" {
  269. where = where + " and a.QQ like '%" + QQ + "%'"
  270. }
  271. if CompanyUrl != "" {
  272. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  273. }
  274. if SpecSupplier != "" {
  275. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  276. }
  277. if SpecTypeCode != "" {
  278. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  279. }
  280. if SpecTypeName != "" {
  281. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  282. }
  283. if Remark != "" {
  284. where = where + " and a.Remark like '%" + Remark + "%'"
  285. }
  286. if CreateOn != "" {
  287. dates := strings.Split(CreateOn, ",")
  288. if len(dates) == 2 {
  289. minDate := dates[0]
  290. maxDate := dates[1]
  291. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  292. }
  293. }
  294. //企业用户必须加创建人条件
  295. if this.User.IsCompanyUser == 1 {
  296. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  297. } else {
  298. //超级管理员和有查看所有数据权限的用户不加条件
  299. svcPerm := permission.GetPermissionService(utils.DBE)
  300. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  301. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  302. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  303. }
  304. }
  305. svc := infochange.GetInfoChangeService(utils.DBE)
  306. var list []infochange.SuppModelInfo
  307. total := svc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  308. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  309. var datainfo DataInfo
  310. datainfo.Items = list
  311. datainfo.CurrentItemCount = total
  312. datainfo.PageIndex = page.CurrentPage
  313. datainfo.ItemsPerPage = page.Size
  314. this.Data["json"] = &datainfo
  315. this.ServeJSON()
  316. }
  317. // @Title 获取列表
  318. // @Description get user by token
  319. // @Success 200 {object} []infochange.OilInfoChange
  320. // @router /alllist [get]
  321. func (this *InfoChangeController) GetAllEntityList() {
  322. //获取分页信息
  323. page := this.GetPageInfoForm()
  324. where := " 1=1 "
  325. orderby := "Id"
  326. asc := false
  327. Order := this.GetString("Order")
  328. Prop := this.GetString("Prop")
  329. if Order != "" && Prop != "" {
  330. orderby = Prop
  331. if Order == "asc" {
  332. asc = true
  333. }
  334. }
  335. SupplierTypeName := this.GetString("SupplierTypeName")
  336. RecUnitId := this.GetString("RecUnitId")
  337. AccessCardNo := this.GetString("AccessCardNo")
  338. SupplierName := this.GetString("SupplierName")
  339. CreateOn := this.GetString("CreateOn")
  340. if SupplierTypeName != "" {
  341. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  342. }
  343. if RecUnitId != "" {
  344. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  345. }
  346. if AccessCardNo != "" {
  347. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  348. }
  349. if SupplierName != "" {
  350. where = where + " and SupplierName like '%" + SupplierName + "%'"
  351. }
  352. if CreateOn != "" {
  353. dates := strings.Split(CreateOn, ",")
  354. if len(dates) == 2 {
  355. minDate := dates[0]
  356. maxDate := dates[1]
  357. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  358. }
  359. }
  360. svc := infochange.GetInfoChangeService(utils.DBE)
  361. var list []infochange.OilInfoChange
  362. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  363. var datainfo DataInfo
  364. datainfo.Items = list
  365. datainfo.CurrentItemCount = total
  366. datainfo.PageIndex = page.CurrentPage
  367. datainfo.ItemsPerPage = page.Size
  368. this.Data["json"] = &datainfo
  369. this.ServeJSON()
  370. }
  371. // @Title 获取列表
  372. // @Description get user by token
  373. // @Success 200 {object} []infochange.OilInfoChange
  374. // @router /list [get]
  375. func (this *InfoChangeController) GetEntityList() {
  376. //获取分页信息
  377. page := this.GetPageInfoForm()
  378. where := " 1=1 "
  379. orderby := "Id"
  380. asc := false
  381. Order := this.GetString("Order")
  382. Prop := this.GetString("Prop")
  383. if Order != "" && Prop != "" {
  384. orderby = Prop
  385. if Order == "asc" {
  386. asc = true
  387. }
  388. }
  389. SupplierTypeName := this.GetString("SupplierTypeName")
  390. RecUnitId := this.GetString("RecUnitId")
  391. AccessCardNo := this.GetString("AccessCardNo")
  392. SupplierName := this.GetString("SupplierName")
  393. CreateOn := this.GetString("CreateOn")
  394. if SupplierTypeName != "" {
  395. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  396. }
  397. if RecUnitId != "" {
  398. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  399. }
  400. if AccessCardNo != "" {
  401. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  402. }
  403. if SupplierName != "" {
  404. where = where + " and SupplierName like '%" + SupplierName + "%'"
  405. }
  406. if CreateOn != "" {
  407. dates := strings.Split(CreateOn, ",")
  408. if len(dates) == 2 {
  409. minDate := dates[0]
  410. maxDate := dates[1]
  411. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  412. }
  413. }
  414. //找出待办任务
  415. actisvc := workflow.GetActivitiService(utils.DBE)
  416. certIdList := actisvc.GetMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
  417. appendIdarr := strings.Split(certIdList, ",")
  418. for i, item := range appendIdarr {
  419. idx := strings.Index(item, "-")
  420. if idx >= 0 {
  421. appendIdarr[i] = strings.Split(item, "-")[0]
  422. }
  423. }
  424. certIdList = strings.Join(appendIdarr, ",")
  425. svc := infochange.GetInfoChangeService(utils.DBE)
  426. var list []infochange.OilInfoChange
  427. var total int64 = 0
  428. if certIdList != "" {
  429. where += " and Id in (" + certIdList + ")"
  430. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  431. }
  432. var datainfo DataInfo
  433. datainfo.Items = list
  434. datainfo.CurrentItemCount = total
  435. datainfo.PageIndex = page.CurrentPage
  436. datainfo.ItemsPerPage = page.Size
  437. this.Data["json"] = &datainfo
  438. this.ServeJSON()
  439. }
  440. // @Title 获取实体
  441. // @Description 获取实体
  442. // @Success 200 {object} annualaudit.OilAnnualAudit
  443. // @router /getinfoforitem [get]
  444. func (this *InfoChangeController) GetInfoForItem() {
  445. certId := this.GetString("certId")
  446. selctitem := this.GetString("selctitem")
  447. svc := infochange.GetInfoChangeService(utils.DBE)
  448. where := "Id =" + utils.ToStr(certId)
  449. var selecteditem = svc.GetInfoforItem(""+OilSupplierName, selctitem, where)
  450. this.Data["json"] = &selecteditem
  451. this.ServeJSON()
  452. }
  453. // @Title 获取实体
  454. // @Description 获取实体
  455. // @Success 200 {object} supplier.OilSupplier
  456. // @router /getchangelist/:id [get]
  457. func (this *InfoChangeController) GetChangeEntity() {
  458. Id := this.Ctx.Input.Param(":id")
  459. var model supplier.OilSupplier
  460. svc := supplier.GetOilSupplierService(utils.DBE)
  461. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  462. var infoitems []infochange.OilInfoChangeItem
  463. where := " SupplierId = " + Id
  464. where = where + " and ChangeStatus = 0"
  465. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoitems)
  466. immumodel := reflect.ValueOf(&model)
  467. elem := immumodel.Elem()
  468. for _, info := range infoitems {
  469. fmt.Println(info.SelectItem)
  470. fmt.Println(";;;;;;;;;", elem.FieldByName(info.SelectItem).Type().String())
  471. if elem.FieldByName(info.SelectItem).Type().String() == "int64" {
  472. intchangeinfo, _ := strconv.ParseInt(info.ChangeInfo, 10, 64)
  473. elem.FieldByName(info.SelectItem).SetInt(intchangeinfo)
  474. } else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
  475. t, _ := time.Parse("2006-01-02", info.ChangeInfo)
  476. elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
  477. } else {
  478. elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
  479. }
  480. }
  481. this.Data["json"] = &model
  482. this.ServeJSON()
  483. }
  484. // @Title 获取列表
  485. // @Description get user by token
  486. // @Success 200 {object} []annualaudit.OilAnnualAudit
  487. // @router /mytasks [get]
  488. func (this *InfoChangeController) GetMyTaskEntityList() {
  489. //获取分页信息
  490. page := this.GetPageInfoForm()
  491. where := " 1=1 "
  492. orderby := "Id"
  493. asc := false
  494. Order := this.GetString("Order")
  495. Prop := this.GetString("Prop")
  496. if Order != "" && Prop != "" {
  497. orderby = Prop
  498. if Order == "asc" {
  499. asc = true
  500. }
  501. }
  502. SupplierTypeName := this.GetString("SupplierTypeName")
  503. RecUnitId := this.GetString("RecUnitId")
  504. AccessCardNo := this.GetString("AccessCardNo")
  505. SupplierName := this.GetString("SupplierName")
  506. CreateOn := this.GetString("CreateOn")
  507. if SupplierTypeName != "" {
  508. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  509. }
  510. if RecUnitId != "" {
  511. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  512. }
  513. if AccessCardNo != "" {
  514. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  515. }
  516. if SupplierName != "" {
  517. where = where + " and SupplierName like '%" + SupplierName + "%'"
  518. }
  519. if CreateOn != "" {
  520. dates := strings.Split(CreateOn, ",")
  521. if len(dates) == 2 {
  522. minDate := dates[0]
  523. maxDate := dates[1]
  524. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  525. }
  526. }
  527. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  528. var list []annualaudit.OilAnnualAudit
  529. //找出待办任务
  530. actisvc := workflow.GetActivitiService(utils.DBE)
  531. certIdList := actisvc.GetMyTasks(workflow.OIL_AUDIT_APPLY, this.User.Id)
  532. where += " and Id in (" + certIdList + ")"
  533. where += " and Status != -2 "
  534. //根据部门查询待办任务
  535. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  536. //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  537. var datainfo DataInfo
  538. datainfo.Items = list
  539. datainfo.CurrentItemCount = total
  540. datainfo.PageIndex = page.CurrentPage
  541. datainfo.ItemsPerPage = page.Size
  542. this.Data["json"] = &datainfo
  543. this.ServeJSON()
  544. }
  545. // @Title 删除单条信息
  546. // @Description
  547. // @Success 200 {object} ErrorInfo
  548. // @Failure 403 :id 为空
  549. // @router /delete/:Id [delete]
  550. func (this *InfoChangeController) DeleteEntity() {
  551. Id := this.Ctx.Input.Param(":Id")
  552. var errinfo ErrorInfo
  553. if Id == "" {
  554. errinfo.Message = "操作失败!请求信息不完整"
  555. errinfo.Code = -2
  556. this.Data["json"] = &errinfo
  557. this.ServeJSON()
  558. return
  559. }
  560. var model infochange.OilInfoChangeItem
  561. var entityempty infochange.OilInfoChangeItem
  562. svc := infochange.GetInfoChangeService(utils.DBE)
  563. opdesc := "删除-" + Id
  564. err := svc.DeleteOperationAndWriteLogBytbl(""+OilInfoChangeItemName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "信息变更")
  565. if err == nil {
  566. errinfo.Message = "删除成功"
  567. errinfo.Code = 0
  568. this.Data["json"] = &errinfo
  569. this.ServeJSON()
  570. } else {
  571. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  572. errinfo.Code = -1
  573. this.Data["json"] = &errinfo
  574. this.ServeJSON()
  575. }
  576. }
  577. // @Title 添加
  578. // @Description 新增
  579. // @Success 200 {object} controllers.Request
  580. // @router /addinfochangeitem [post]
  581. func (this *InfoChangeController) AddInfoChangeItem() {
  582. var model infochange.OilInfoChangeItem
  583. var jsonBlob = this.Ctx.Input.RequestBody
  584. svc := infochange.GetInfoChangeService(utils.DBE)
  585. json.Unmarshal(jsonBlob, &model)
  586. model.CreateOn = time.Now()
  587. model.CreateBy = this.User.Realname
  588. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  589. _, err := svc.InsertEntityBytbl(""+OilInfoChangeItemName, &model)
  590. var errinfo ErrorDataInfo
  591. if err == nil {
  592. //新增
  593. errinfo.Message = "添加成功!"
  594. errinfo.Code = 0
  595. errinfo.Item = model.Id
  596. this.Data["json"] = &errinfo
  597. this.ServeJSON()
  598. } else {
  599. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  600. errinfo.Code = -1
  601. this.Data["json"] = &errinfo
  602. this.ServeJSON()
  603. }
  604. }
  605. // @Title 添加
  606. // @Description 新增
  607. // @Success 200 {object} controllers.Request
  608. // @router /addinfochangeitemch [post]
  609. func (this *InfoChangeController) AddInfoChangeItemCh() {
  610. var model InfoChangeItemsAll
  611. var jsonBlob = this.Ctx.Input.RequestBody
  612. svc := infochange.GetInfoChangeService(utils.DBE)
  613. json.Unmarshal(jsonBlob, &model)
  614. var err error
  615. where := " SupplierId = " + model.SupplierId
  616. where = where + " and InfoId = " + model.MInfoId
  617. for i := 0; i < len(model.InfochangeForm); i++ {
  618. var infoitementity infochange.OilInfoChangeItem
  619. infoitementity.SelectItem = model.InfochangeForm[i].SelectItem
  620. infoitementity.ChangeInfo = model.InfochangeForm[i].ChangeInfo
  621. infoitementity.BeChangeInfo = model.InfochangeForm[i].BeChangeInfo
  622. infoitementity.ChangeStatus = 0
  623. infoitementity.SupplierId, _ = strconv.Atoi(model.SupplierId)
  624. infoitementity.InfoId, _ = strconv.Atoi(model.MInfoId)
  625. where = where + " and SelectItem = '" + model.InfochangeForm[i].SelectItem + "'"
  626. var infoitemmodel []infochange.OilInfoChangeItem
  627. svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoitemmodel)
  628. if len(infoitemmodel) > 0 {
  629. cols := []string{"ChangeInfo", "BeChangeInfo", "ChangeStatus"}
  630. svc.UpdateEntityBywheretbl(OilInfoChangeItemName, &infoitementity, cols, where)
  631. } else {
  632. infoitementity.CreateOn = time.Now()
  633. infoitementity.CreateBy = this.User.Realname
  634. infoitementity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  635. _, err = svc.InsertEntityBytbl(""+OilInfoChangeItemName, &infoitementity)
  636. }
  637. }
  638. var errinfo ErrorDataInfo
  639. if err == nil {
  640. //新增
  641. errinfo.Message = "添加成功!"
  642. errinfo.Code = 0
  643. //errinfo.Item = model.Id
  644. this.Data["json"] = &errinfo
  645. this.ServeJSON()
  646. } else {
  647. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  648. errinfo.Code = -1
  649. this.Data["json"] = &errinfo
  650. this.ServeJSON()
  651. }
  652. }
  653. // @Title 获取二级初审人员
  654. // @Description 获取二级初审人员
  655. // @router /getauditerbydept/:deptId [get]
  656. func (this *InfoChangeController) GetAuditerByDept() {
  657. Id := this.Ctx.Input.Param(":deptId")
  658. //var auditWorkflow auditsetting.Base_OilAuditSetting
  659. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  660. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, Id, workflow.FIRST_TRIAL, &auditWorkflow)
  661. var userlist []userRole.Base_User
  662. where := " CompanyId = " + Id
  663. rsvc.GetEntities(&userlist, where)
  664. var datainfo ErrorDataInfo
  665. datainfo.Item = userlist
  666. this.Data["json"] = &datainfo
  667. this.ServeJSON()
  668. }
  669. // @Title 获取企业法规处人员
  670. // @Description 获取企业法规处人员
  671. // @router /getauditer [get]
  672. func (this *InfoChangeController) GetAuditer() {
  673. //svc := infochange.GetInfoChangeService(utils.DBE)
  674. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  675. var users []userRole.Base_RoleList
  676. certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
  677. //var users []suppliercert.UserList
  678. // where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
  679. //svc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  680. var datainfo ErrorDataInfo
  681. datainfo.Item = users
  682. this.Data["json"] = &datainfo
  683. this.ServeJSON()
  684. }
  685. // @Title 添加
  686. // @Description 新增信息变更
  687. // @Success 200 {object} controllers.Request
  688. // @router /addinfomain [post]
  689. func (this *InfoChangeController) AddInfoMain() {
  690. SupplierId := this.GetString("SupplierId")
  691. Remark := this.GetString("Remark")
  692. var infochmain infochange.OilInfoChange
  693. var infochm []infochange.OilInfoChange
  694. var suppliermodel supplier.OilSupplier
  695. var errinfo ErrorDataInfo
  696. svc := infochange.GetInfoChangeService(utils.DBE)
  697. where := " SupplierId = " + SupplierId + " and Status < 4"
  698. svc.GetEntitysByWhere(OilInfoChangeName, where, &infochm)
  699. if len(infochm) > 0 {
  700. errinfo.Message = "有已提交在申请中的信息变更,请审批完成后再提交!"
  701. errinfo.Code = -1
  702. this.Data["json"] = &errinfo
  703. this.ServeJSON()
  704. return
  705. }
  706. svc.GetEntityById(SupplierId, &suppliermodel)
  707. infochmain.OldSupplierName = suppliermodel.SupplierName
  708. infochmain.MgrUnit = suppliermodel.MgrUnit
  709. infochmain.OilCertificateNo = suppliermodel.OilCertificateNo
  710. infochmain.OperType = suppliermodel.OperType
  711. infochmain.Country = suppliermodel.Country
  712. infochmain.MaunAgent = suppliermodel.MaunAgent
  713. infochmain.CommercialNo = suppliermodel.CommercialNo
  714. infochmain.OrganCode = suppliermodel.OrganCode
  715. infochmain.SupplierId, _ = strconv.Atoi(SupplierId)
  716. infochmain.Remark = Remark
  717. infochmain.CreateOn = time.Now()
  718. infochmain.CreateBy = this.User.Realname
  719. infochmain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  720. _, err := svc.InsertEntityBytbl(OilInfoChangeName, &infochmain)
  721. if err == nil {
  722. errinfo.Message = "添加成功!"
  723. errinfo.Code = 0
  724. errinfo.Item = infochmain.Id
  725. this.Data["json"] = &errinfo
  726. this.ServeJSON()
  727. } else {
  728. errinfo.Message = "添加失败!"
  729. errinfo.Code = -1
  730. this.Data["json"] = &errinfo
  731. this.ServeJSON()
  732. }
  733. }
  734. // @Title 获取信息变更企业名称
  735. // @Description 获取实体
  736. // @Success 200 {object}
  737. // @router /addsupplierlist [get]
  738. func (this *InfoChangeController) GetAddSupplierList() {
  739. svc := infochange.GetInfoChangeService(utils.DBE)
  740. var supplierlist []annualaudit.Suppliername
  741. where := "1=1"
  742. //企业用户必须加创建人条件
  743. if this.User.IsCompanyUser == 1 {
  744. where = where + " and CreateUserId = '" + this.User.Id + "'"
  745. } else {
  746. //超级管理员和有查看所有数据权限的用户不加条件
  747. svcPerm := permission.GetPermissionService(utils.DBE)
  748. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  749. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  750. where = where + " and CreateUserId = '" + this.User.Id + "'"
  751. }
  752. }
  753. supplierlist = svc.GetSupplierList(""+OilSupplierName, where)
  754. var datainfo DataInfo
  755. datainfo.Items = supplierlist
  756. this.Data["json"] = &datainfo
  757. this.ServeJSON()
  758. }
  759. // @Title 提交审批
  760. // @Description 提交审批
  761. // @Success 200 {object} controllers.Request
  762. // @router /commitaudit/:id [post]
  763. func (this *InfoChangeController) CommitAuditEntity() {
  764. //suppId := this.Ctx.Input.Param(":id")
  765. firstAudit := this.GetString("auditer")
  766. fushenauditer := this.GetString("fushenauditer")
  767. Remark := this.GetString("Remark")
  768. InfoId := this.GetString("MInfoId")
  769. //取出审批列表
  770. svc := infochange.GetInfoChangeService(utils.DBE)
  771. var infochangeentity infochange.OilInfoChange
  772. infwhere := " Id = " + InfoId
  773. svc.GetEntity(&infochangeentity, infwhere)
  774. var errinfo ErrorDataInfo
  775. defer func() { //finally处理失败的异常
  776. if err := recover(); err != nil {
  777. errinfo.Message = "提交失败," + err.(string)
  778. errinfo.Code = -1
  779. this.Data["json"] = &errinfo
  780. this.ServeJSON()
  781. } else {
  782. //返回正确结果
  783. errinfo.Message = "审核提交成功"
  784. errinfo.Code = 0
  785. this.Data["json"] = &errinfo
  786. this.ServeJSON()
  787. }
  788. }()
  789. svcActiviti := workflow.GetActivitiService(utils.DBE)
  790. processInstanceId := ""
  791. businessKey := ""
  792. businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
  793. processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id)
  794. var ActiComplete workflow.ActiCompleteVM
  795. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  796. ActiComplete.BusinessKey = businessKey
  797. ActiComplete.UserNames = firstAudit
  798. ActiComplete.UserId = this.User.Id
  799. ActiComplete.Result = "1"
  800. ActiComplete.Remarks = Remark
  801. ActiComplete.CallbackUrl = ""
  802. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  803. if receiveVal == "true" {
  804. errinfo.Message = "提交成功!"
  805. errinfo.Code = 0
  806. this.Data["json"] = &errinfo
  807. this.ServeJSON()
  808. } else {
  809. errinfo.Message = "工作流异常,请联系管理员!"
  810. errinfo.Code = -1
  811. this.Data["json"] = &errinfo
  812. this.ServeJSON()
  813. return
  814. }
  815. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  816. infochangeentity.WorkFlowId = processInstanceId
  817. infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  818. infochangeentity.FirstAudit, _ = strconv.Atoi(firstAudit)
  819. infochangeentity.SecondAudit, _ = strconv.Atoi(fushenauditer)
  820. infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
  821. infochangeentity.BusinessKey = ActiComplete.BusinessKey
  822. infochangeentity.CreateOn = time.Now()
  823. infochangeentity.CreateBy = this.User.Realname
  824. infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  825. cols := []string{
  826. "Id",
  827. "WorkflowId",
  828. "Status",
  829. "Step",
  830. "FirstAudit",
  831. "SecondAudit",
  832. "AuditIndex",
  833. "BusinessKey",
  834. "CreateOn",
  835. "CreateBy",
  836. "CreateUserId",
  837. }
  838. svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
  839. }
  840. // @Title 提交审批
  841. // @Description 提交审批
  842. // @Success 200 {object} controllers.Request
  843. // @router /audit/:id [post]
  844. func (this *InfoChangeController) AuditEntity() {
  845. suppId := this.Ctx.Input.Param(":id")
  846. firstAudit := this.GetString("auditer")
  847. Remark := this.GetString("Remark")
  848. InfoId := this.GetString("MInfoId")
  849. //取出审批列表
  850. svc := infochange.GetInfoChangeService(utils.DBE)
  851. var infoitems []infochange.OilInfoChangeItem
  852. where := " SupplierId = " + suppId
  853. svc.GetEntities(&infoitems, where)
  854. var infochangeentity infochange.OilInfoChange
  855. infwhere := " Id = " + InfoId
  856. svc.GetEntity(&infochangeentity, infwhere)
  857. var infomodel infochange.OilInfoChangeItem
  858. var errinfo ErrorDataInfo
  859. defer func() { //finally处理失败的异常
  860. if err := recover(); err != nil {
  861. errinfo.Message = "提交失败," + err.(string)
  862. errinfo.Code = -1
  863. this.Data["json"] = &errinfo
  864. this.ServeJSON()
  865. } else {
  866. //返回正确结果
  867. errinfo.Message = "审核提交成功"
  868. errinfo.Code = 0
  869. this.Data["json"] = &errinfo
  870. this.ServeJSON()
  871. }
  872. }()
  873. var items string
  874. for i := 0; i < len(infoitems); i++ {
  875. items = fmt.Sprintf("%s %s %s %s", items, infoitems[i].SelectItem, ","+infoitems[i].BeChangeInfo, ","+infoitems[i].ChangeInfo+";")
  876. }
  877. items = strings.Trim(items, ";")
  878. infowhere := " Id = " + InfoId
  879. svc.Updateentityinfo(OilInfoChangeName, items, infowhere)
  880. //修改从表infoid
  881. for i := 0; i < len(infoitems); i++ {
  882. infomodel.InfoId, _ = strconv.Atoi(InfoId)
  883. err := svc.UpdateEntityBytbl(OilInfoChangeItemName, infoitems[i].Id, &infomodel, []string{"InfoId"})
  884. fmt.Println(err)
  885. }
  886. svcActiviti := workflow.GetActivitiService(utils.DBE)
  887. processInstanceId := ""
  888. businessKey := ""
  889. if infochangeentity.WorkFlowId == "0" || len(infochangeentity.WorkFlowId) <= 0 {
  890. //启动工作流
  891. businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
  892. processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id)
  893. }
  894. var ActiComplete workflow.ActiCompleteVM
  895. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  896. ActiComplete.BusinessKey = businessKey
  897. ActiComplete.UserNames = firstAudit
  898. ActiComplete.UserId = this.User.Id
  899. ActiComplete.Result = "1"
  900. ActiComplete.Remarks = Remark
  901. ActiComplete.CallbackUrl = ""
  902. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  903. if receiveVal == "true" {
  904. errinfo.Message = "提交成功!"
  905. errinfo.Code = 0
  906. this.Data["json"] = &errinfo
  907. this.ServeJSON()
  908. } else {
  909. errinfo.Message = "工作流异常,请联系管理员!"
  910. errinfo.Code = -1
  911. this.Data["json"] = &errinfo
  912. this.ServeJSON()
  913. return
  914. }
  915. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  916. infochangeentity.WorkFlowId = processInstanceId
  917. infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  918. infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
  919. infochangeentity.BusinessKey = ActiComplete.BusinessKey
  920. infochangeentity.CreateOn = time.Now()
  921. infochangeentity.CreateBy = this.User.Realname
  922. infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  923. cols := []string{
  924. "Id",
  925. "WorkflowId",
  926. "Status",
  927. "Step",
  928. "FirstAudit",
  929. "AuditIndex",
  930. "BusinessKey",
  931. "CreateOn",
  932. "CreateBy",
  933. "CreateUserId",
  934. }
  935. svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
  936. }
  937. // @Title 审批
  938. // @Description 审批
  939. // @Success 200 {object} controllers.Request
  940. // @router /infoaudit [post]
  941. func (this *InfoChangeController) InfoAudit() {
  942. svc := infochange.GetInfoChangeService(utils.DBE)
  943. var jsonblob = this.Ctx.Input.RequestBody
  944. var dataother InfoShenHeModel
  945. json.Unmarshal(jsonblob, &dataother)
  946. //取出审批列表
  947. var infoid = dataother.InfoId
  948. var infomodel infochange.OilInfoChange
  949. svc.GetEntityById(utils.ToStr(dataother.InfoId), &infomodel)
  950. var infoitems []infochange.OilInfoChangeItem
  951. where := "SupplierId = " + utils.ToStr(dataother.SuppId)
  952. svc.GetEntities(&infoitems, where)
  953. var errinfo ErrorDataInfo
  954. defer func() { //finally处理失败的异常
  955. if err := recover(); err != nil {
  956. errinfo.Message = "提交失败," + err.(string)
  957. errinfo.Code = -1
  958. this.Data["json"] = &errinfo
  959. this.ServeJSON()
  960. } else {
  961. //返回正确结果
  962. errinfo.Message = "审核提交成功"
  963. errinfo.Code = 0
  964. this.Data["json"] = &errinfo
  965. this.ServeJSON()
  966. }
  967. }()
  968. //审核状态判断进行的操作
  969. step := 2
  970. status := ""
  971. backstatus := "0"
  972. var userIds string
  973. if infomodel.Status == suppliercert.FIRST_TRIAL_STATUS {
  974. userIds = utils.ToStr(infomodel.SecondAudit)
  975. status = suppliercert.SECOND_TRIAL_STATUS
  976. step = 2
  977. backstatus = suppliercert.NOPASS_STATUS
  978. } else if infomodel.Status == suppliercert.SECOND_TRIAL_STATUS {
  979. status = suppliercert.THIRD_TRIAL_STATUS
  980. backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
  981. step = 2
  982. dictSvc := items.GetItemsService(utils.DBE)
  983. deptIds := dictSvc.GetKeyValueItems("CENT_AUDIT")
  984. var users []userRole.Base_RoleList
  985. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  986. for _, dept := range deptIds {
  987. certSrv.GetAuditUser(dept.Value, workflow.PROF_REGULATION, &users)
  988. for _, tmpUser := range users {
  989. userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  990. }
  991. }
  992. userIds = strings.Trim(userIds, ",")
  993. }else if infomodel.Status == suppliercert.THIRD_TRIAL_STATUS {
  994. status = suppliercert.PROF_AUDIT_STATUS
  995. step = 3
  996. backstatus = suppliercert.NO_THIRD_TRIAL_STATUS
  997. }
  998. svcActiviti := workflow.GetActivitiService(utils.DBE)
  999. var ActiComplete workflow.ActiCompleteVM
  1000. ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
  1001. ActiComplete.BusinessKey = infomodel.BusinessKey
  1002. ActiComplete.UserNames = userIds
  1003. ActiComplete.UserId = this.User.Id
  1004. ActiComplete.Remarks = dataother.AuditorRemark
  1005. ActiComplete.CallbackUrl = ""
  1006. var myerr error
  1007. if dataother.SuccessStatus == 1 {
  1008. ActiComplete.Result = "1"
  1009. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1010. infomodel.Status = status
  1011. if infomodel.Status == suppliercert.THIRD_TRIAL_STATUS {
  1012. var infochangeitemmodel infochange.OilInfoChangeItem
  1013. infochangeitemmodel.ChangeStatus = 1
  1014. itemswhere := "InfoId = " + utils.ToStr(infoid)
  1015. myerr = svc.UpdateEntityBywheretbl(OilInfoChangeItemName, &infochangeitemmodel, []string{"ChangeStatus"}, itemswhere)
  1016. myerr = this.updatesupplier(dataother.SuppId, infoitems, infomodel)
  1017. }
  1018. infomodel.Step = step
  1019. if receiveVal == "true" {
  1020. cols := []string{
  1021. "Id",
  1022. "Status",
  1023. "Step",
  1024. }
  1025. _, myerr = svc.UpdateEntityByIdCols(infoid, infomodel, cols)
  1026. if myerr == nil {
  1027. errinfo.Message = "提交成功!"
  1028. errinfo.Code = 0
  1029. this.Data["json"] = &errinfo
  1030. this.ServeJSON()
  1031. } else {
  1032. errinfo.Message = "提交失败!"
  1033. errinfo.Code = -1
  1034. this.Data["json"] = &errinfo
  1035. this.ServeJSON()
  1036. }
  1037. } else {
  1038. errinfo.Message = "工作流异常,请联系管理员!"
  1039. errinfo.Code = -1
  1040. this.Data["json"] = &errinfo
  1041. this.ServeJSON()
  1042. return
  1043. }
  1044. } else {
  1045. ActiComplete.Result = "0"
  1046. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1047. if receiveVal == "true" {
  1048. if infomodel.Status == suppliercert.THIRD_TRIAL_STATUS {
  1049. infomodel.Status = suppliercert.NO_CENT_AUDIT_STATUS
  1050. } else {
  1051. infomodel.Status = backstatus
  1052. // 审批历史
  1053. var audithistoryentity audithistory.Base_AuditHistory
  1054. audithistoryentity.EntityId = infoid
  1055. audithistoryentity.WorkflowId = infomodel.WorkFlowId
  1056. audithistoryentity.Process = ActiComplete.ProcessKey
  1057. audithistoryentity.BusinessKey = ActiComplete.BusinessKey
  1058. audithistoryentity.Type = "04"
  1059. audithistoryentity.BackStep = infomodel.Status
  1060. audithistoryentity.Index = infomodel.AuditIndex
  1061. audithistoryentity.CreateOn = time.Now()
  1062. audithistoryentity.CreateBy = this.User.Realname
  1063. audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1064. _, myerr = svc.InsertEntity(audithistoryentity)
  1065. infomodel.WorkFlowId = ""
  1066. }
  1067. infomodel.Step = 1
  1068. cols := []string{
  1069. "Status",
  1070. "Step",
  1071. }
  1072. _, myerr := svc.UpdateEntityByIdCols(infoid, infomodel, cols)
  1073. if myerr == nil {
  1074. errinfo.Message = "提交成功!"
  1075. errinfo.Code = 0
  1076. this.Data["json"] = &errinfo
  1077. this.ServeJSON()
  1078. } else {
  1079. errinfo.Message = "提交失败!"
  1080. errinfo.Code = -1
  1081. this.Data["json"] = &errinfo
  1082. this.ServeJSON()
  1083. }
  1084. } else {
  1085. errinfo.Message = "工作流异常,请联系管理员!"
  1086. errinfo.Code = -1
  1087. this.Data["json"] = &errinfo
  1088. this.ServeJSON()
  1089. return
  1090. }
  1091. }
  1092. }
  1093. //更新供方信息表
  1094. func (this *InfoChangeController) updatesupplier(suppid int, infoitems []infochange.OilInfoChangeItem, infomodel infochange.OilInfoChange) error {
  1095. svc := infochange.GetInfoChangeService(utils.DBE)
  1096. var err error
  1097. var cols []string
  1098. if len(infoitems) > 0 {
  1099. for i := 0; i < len(infoitems); i++ {
  1100. cols = append(cols, infoitems[i].SelectItem)
  1101. }
  1102. }
  1103. err = svc.UpdateEntityBytbl(OilSupplierName, suppid, &infomodel, cols)
  1104. return err
  1105. }