infochange.go 43 KB

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