suppliercert.go 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/audithistory"
  4. "dashoo.cn/backend/api/business/codecsequence"
  5. msg2 "dashoo.cn/backend/api/business/msg"
  6. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  7. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  8. "dashoo.cn/backend/api/business/oilsupplier/oilactivity"
  9. "dashoo.cn/backend/api/business/oilsupplier/oilcostmanage"
  10. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  11. "dashoo.cn/backend/api/business/oilsupplier/supplierapplytime"
  12. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  13. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  14. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  15. "dashoo.cn/backend/api/business/organize"
  16. "dashoo.cn/backend/api/business/paymentinfo"
  17. "dashoo.cn/business2/parameter"
  18. "encoding/json"
  19. "fmt"
  20. "strconv"
  21. "strings"
  22. "time"
  23. "unicode/utf8"
  24. "dashoo.cn/backend/api/business/auditsetting"
  25. "dashoo.cn/backend/api/business/workflow"
  26. "dashoo.cn/backend/api/business/baseUser"
  27. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  28. . "dashoo.cn/backend/api/controllers"
  29. "dashoo.cn/business2/userRole"
  30. "dashoo.cn/utils"
  31. )
  32. type OilSupplierCertController struct {
  33. BaseController
  34. }
  35. // @Title 获取列表
  36. // @Description get user by token
  37. // @Success 200 {object} []suppliercert.OilSupplierCert
  38. // @router /list [get]
  39. func (this *OilSupplierCertController) GetEntityList() {
  40. //获取分页信息
  41. page := this.GetPageInfoForm()
  42. where := " 1=1 "
  43. orderby := "Id"
  44. asc := false
  45. Order := this.GetString("Order")
  46. Prop := this.GetString("Prop")
  47. if Order != "" && Prop != "" {
  48. orderby = Prop
  49. if Order == "asc" {
  50. asc = true
  51. }
  52. }
  53. Id := this.GetString("Id")
  54. SupplierId := this.GetString("SupplierId")
  55. AccessCardNo := this.GetString("AccessCardNo")
  56. SupplierTypeCode := this.GetString("SupplierTypeCode")
  57. SupplierTypeName := this.GetString("SupplierTypeName")
  58. RecUnitReason := this.GetString("RecUnitReason")
  59. RecUnitPerson := this.GetString("RecUnitPerson")
  60. RecDate := this.GetString("RecDate")
  61. RecUnitId := this.GetString("RecUnitId")
  62. RecUnitName := this.GetString("RecUnitName")
  63. StatusA := this.GetString("StatusA")
  64. BackReason := this.GetString("BackReason")
  65. InFlag := this.GetString("InFlag")
  66. EffectStartTime := this.GetString("EffectStartTime")
  67. EffectEndTime := this.GetString("EffectEndTime")
  68. AuditProcessNote := this.GetString("AuditProcessNote")
  69. AuditDate := this.GetString("AuditDate")
  70. PayNotice := this.GetString("PayNotice")
  71. SupplierStatus := this.GetString("SupplierStatus")
  72. MgrType := this.GetString("MgrType")
  73. Type := this.GetString("Type")
  74. MgrUnit := this.GetString("MgrUnit")
  75. AddinTime := this.GetString("AddinTime")
  76. EffectTime := this.GetString("EffectTime")
  77. ApplyTime := this.GetString("ApplyTime")
  78. SupplierNo := this.GetString("SupplierNo")
  79. MDMFlag := this.GetString("MDMFlag")
  80. InternalFlag := this.GetString("InternalFlag")
  81. ImportFlag := this.GetString("ImportFlag")
  82. OutsideFlog := this.GetString("OutsideFlog")
  83. Remark := this.GetString("Remark")
  84. IsDelete := this.GetString("IsDelete")
  85. CreateOn := this.GetString("CreateOn")
  86. CreateUserId := this.GetString("CreateUserId")
  87. CreateBy := this.GetString("CreateBy")
  88. ModifiedOn := this.GetString("ModifiedOn")
  89. ModifiedUserId := this.GetString("ModifiedUserId")
  90. ModifiedBy := this.GetString("ModifiedBy")
  91. if Id != "" {
  92. where = where + " and Id like '%" + Id + "%'"
  93. }
  94. if SupplierId != "" {
  95. where = where + " and SupplierId like '%" + SupplierId + "%'"
  96. }
  97. if AccessCardNo != "" {
  98. where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
  99. }
  100. if SupplierTypeCode != "" {
  101. where = where + " and SupplierTypeCode like '%" + SupplierTypeCode + "%'"
  102. }
  103. if SupplierTypeName != "" {
  104. where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
  105. }
  106. if RecUnitReason != "" {
  107. where = where + " and RecUnitReason like '%" + RecUnitReason + "%'"
  108. }
  109. if RecUnitPerson != "" {
  110. where = where + " and RecUnitPerson like '%" + RecUnitPerson + "%'"
  111. }
  112. if RecDate != "" {
  113. where = where + " and RecDate like '%" + RecDate + "%'"
  114. }
  115. if RecUnitId != "" {
  116. where = where + " and RecUnitId like '%" + RecUnitId + "%'"
  117. }
  118. if RecUnitName != "" {
  119. where = where + " and RecUnitName like '%" + RecUnitName + "%'"
  120. }
  121. if StatusA != "" {
  122. where = where + " and StatusA like '%" + StatusA + "%'"
  123. }
  124. if BackReason != "" {
  125. where = where + " and BackReason like '%" + BackReason + "%'"
  126. }
  127. if InFlag != "" {
  128. where = where + " and InFlag like '%" + InFlag + "%'"
  129. }
  130. if EffectStartTime != "" {
  131. where = where + " and EffectStartTime like '%" + EffectStartTime + "%'"
  132. }
  133. if EffectEndTime != "" {
  134. where = where + " and EffectEndTime like '%" + EffectEndTime + "%'"
  135. }
  136. if AuditProcessNote != "" {
  137. where = where + " and AuditProcessNote like '%" + AuditProcessNote + "%'"
  138. }
  139. if AuditDate != "" {
  140. where = where + " and AuditDate like '%" + AuditDate + "%'"
  141. }
  142. if PayNotice != "" {
  143. where = where + " and PayNotice like '%" + PayNotice + "%'"
  144. }
  145. if SupplierStatus != "" {
  146. where = where + " and SupplierStatus like '%" + SupplierStatus + "%'"
  147. }
  148. if MgrType != "" {
  149. where = where + " and MgrType like '%" + MgrType + "%'"
  150. }
  151. if Type != "" {
  152. where = where + " and Type like '%" + Type + "%'"
  153. }
  154. if MgrUnit != "" {
  155. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  156. }
  157. if AddinTime != "" {
  158. where = where + " and AddinTime like '%" + AddinTime + "%'"
  159. }
  160. if EffectTime != "" {
  161. where = where + " and EffectTime like '%" + EffectTime + "%'"
  162. }
  163. if ApplyTime != "" {
  164. where = where + " and ApplyTime like '%" + ApplyTime + "%'"
  165. }
  166. if SupplierNo != "" {
  167. where = where + " and SupplierNo like '%" + SupplierNo + "%'"
  168. }
  169. if MDMFlag != "" {
  170. where = where + " and MDMFlag like '%" + MDMFlag + "%'"
  171. }
  172. if InternalFlag != "" {
  173. where = where + " and InternalFlag like '%" + InternalFlag + "%'"
  174. }
  175. if ImportFlag != "" {
  176. where = where + " and ImportFlag like '%" + ImportFlag + "%'"
  177. }
  178. if OutsideFlog != "" {
  179. where = where + " and OutsideFlog like '%" + OutsideFlog + "%'"
  180. }
  181. if Remark != "" {
  182. where = where + " and Remark like '%" + Remark + "%'"
  183. }
  184. if IsDelete != "" {
  185. where = where + " and IsDelete like '%" + IsDelete + "%'"
  186. }
  187. if CreateOn != "" {
  188. where = where + " and CreateOn like '%" + CreateOn + "%'"
  189. }
  190. if CreateUserId != "" {
  191. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  192. }
  193. if CreateBy != "" {
  194. where = where + " and CreateBy like '%" + CreateBy + "%'"
  195. }
  196. if ModifiedOn != "" {
  197. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  198. }
  199. if ModifiedUserId != "" {
  200. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  201. }
  202. if ModifiedBy != "" {
  203. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  204. }
  205. if CreateOn != "" {
  206. dates := strings.Split(CreateOn, ",")
  207. if len(dates) == 2 {
  208. minDate := dates[0]
  209. maxDate := dates[1]
  210. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  211. }
  212. }
  213. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  214. var list []suppliercert.OilSupplierCert
  215. total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
  216. var datainfo DataInfo
  217. datainfo.Items = list
  218. datainfo.CurrentItemCount = total
  219. datainfo.PageIndex = page.CurrentPage
  220. datainfo.ItemsPerPage = page.Size
  221. this.Data["json"] = &datainfo
  222. this.ServeJSON()
  223. }
  224. // @Title 获取字典列表
  225. // @Description get user by token
  226. // @Success 200 {object} map[string]interface{}
  227. // @router /dictlist [get]
  228. func (this *OilSupplierCertController) GetDictList() {
  229. dictList := make(map[string]interface{})
  230. //dictSvc := items.GetItemsService(utils.DBE)
  231. userSvc := baseUser.GetBaseUserService(utils.DBE)
  232. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  233. //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
  234. var userEntity userRole.Base_User
  235. userSvc.GetEntityById(this.User.Id, &userEntity)
  236. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  237. //var dictCustomer []svccustomer.Customer
  238. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  239. //dictList["EntrustCorp"] = &dictCustomer
  240. var datainfo DataInfo
  241. datainfo.Items = dictList
  242. this.Data["json"] = &datainfo
  243. this.ServeJSON()
  244. }
  245. // @Title 获取实体
  246. // @Description 获取实体
  247. // @Success 200 {object} suppliercert.OilSupplierCert
  248. // @router /get/:id [get]
  249. func (this *OilSupplierCertController) GetEntity() {
  250. Id := this.Ctx.Input.Param(":id")
  251. var model suppliercert.OilSupplierCert
  252. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  253. svc.GetEntityByIdBytbl(OilSupplierCertName, Id, &model)
  254. this.Data["json"] = &model
  255. this.ServeJSON()
  256. }
  257. // @Title 获取实体
  258. // @Description 获取实体
  259. // @Success 200 {object} suppliercert.OilSupplierCert
  260. // @router /getbycreatorandtype/:typecode [get]
  261. func (this *OilSupplierCertController) GetEntityByCreatorId() {
  262. creatorId := this.User.Id
  263. typeCode := this.Ctx.Input.Param(":typecode")
  264. var model suppliercert.OilSupplierCert
  265. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  266. where := " CreateUserId = '" + creatorId + "'"
  267. where += " and SupplierTypeCode = '" + typeCode + "'"
  268. svc.GetEntityByWhere(OilSupplierCertName, where, &model)
  269. this.Data["json"] = &model
  270. this.ServeJSON()
  271. }
  272. // @Title 添加
  273. // @Description 新增
  274. // @Success 200 {object} controllers.Request
  275. // @router /add [post]
  276. func (this *OilSupplierCertController) AddEntity() {
  277. var model suppliercert.OilSupplierCert
  278. var jsonBlob = this.Ctx.Input.RequestBody
  279. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  280. json.Unmarshal(jsonBlob, &model)
  281. model.CreateOn = time.Now()
  282. model.CreateBy = this.User.Realname
  283. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  284. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  285. _, err := svc.InsertEntityBytbl(OilSupplierCertName, &model)
  286. var errinfo ErrorDataInfo
  287. if err == nil {
  288. //新增
  289. errinfo.Message = "添加成功!"
  290. errinfo.Code = 0
  291. errinfo.Item = model.Id
  292. this.Data["json"] = &errinfo
  293. this.ServeJSON()
  294. } else {
  295. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  296. errinfo.Code = -1
  297. this.Data["json"] = &errinfo
  298. this.ServeJSON()
  299. }
  300. }
  301. // @Title 修改实体
  302. // @Description 修改实体
  303. // @Success 200 {object} controllers.Request
  304. // @router /update/:id [post]
  305. func (this *OilSupplierCertController) UpdateEntity() {
  306. id := this.Ctx.Input.Param(":id")
  307. var errinfo ErrorInfo
  308. if id == "" {
  309. errinfo.Message = "操作失败!请求信息不完整"
  310. errinfo.Code = -2
  311. this.Data["json"] = &errinfo
  312. this.ServeJSON()
  313. return
  314. }
  315. var model suppliercert.OilSupplierCert
  316. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  317. var jsonBlob = this.Ctx.Input.RequestBody
  318. json.Unmarshal(jsonBlob, &model)
  319. model.ModifiedOn = time.Now()
  320. model.ModifiedBy = this.User.Realname
  321. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  322. cols := []string{
  323. "Id",
  324. "SupplierId",
  325. "AccessCardNo",
  326. "SupplierTypeCode",
  327. "SupplierTypeName",
  328. "RecUnitReason",
  329. "RecUnitPerson",
  330. "RecDate",
  331. "RecUnitId",
  332. "RecUnitName",
  333. "Status",
  334. "BackReason",
  335. "InFlag",
  336. "EffectStartTime",
  337. "EffectEndTime",
  338. "AuditProcessNote",
  339. "AuditDate",
  340. "PayNotice",
  341. "SupplierStatus",
  342. "MgrType",
  343. "Type",
  344. "MgrUnit",
  345. "AddinTime",
  346. "EffectTime",
  347. "ApplyTime",
  348. "SupplierNo",
  349. "MDMFlag",
  350. "InternalFlag",
  351. "ImportFlag",
  352. "OutsideFlog",
  353. "Remark",
  354. "IsDelete",
  355. "CreateOn",
  356. "CreateUserId",
  357. "CreateBy",
  358. "ModifiedOn",
  359. "ModifiedUserId",
  360. "ModifiedBy",
  361. }
  362. err := svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols)
  363. if err == nil {
  364. errinfo.Message = "修改成功!"
  365. errinfo.Code = 0
  366. this.Data["json"] = &errinfo
  367. this.ServeJSON()
  368. } else {
  369. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  370. errinfo.Code = -1
  371. this.Data["json"] = &errinfo
  372. this.ServeJSON()
  373. }
  374. }
  375. // @Title 企业入库
  376. // @Description 企业入库
  377. // @Success 200 {object} controllers.Request
  378. // @router /updatestorage/:id [post]
  379. func (this *OilSupplierCertController) UpdateStorage() {
  380. id := this.Ctx.Input.Param(":id")
  381. status := this.GetString("Status")
  382. PACNumber := this.GetString("PACNumber")
  383. SupplierId := this.GetString("SupplierId")
  384. var errinfo ErrorInfo
  385. if id == "" {
  386. errinfo.Message = "操作失败!请求信息不完整"
  387. errinfo.Code = -2
  388. this.Data["json"] = &errinfo
  389. this.ServeJSON()
  390. return
  391. }
  392. var model suppliercert.OilSupplierCert
  393. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  394. //var jsonBlob = this.Ctx.Input.RequestBody
  395. //json.Unmarshal(jsonBlob, &model)
  396. var err error
  397. if status == suppliercert.NO_CENT_AUDIT_STATUS {
  398. model.Status = suppliercert.DRAFT_STATUS
  399. cols := []string{
  400. "Status",
  401. }
  402. err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols)
  403. } else {
  404. var activity oilactivity.OilActivity
  405. where := "EntityId=" + id + " and ActType='" + oilactivity.STORAGE + "'"
  406. svc.GetEntity(&activity, where)
  407. svcActiviti := workflow.GetActivitiService(utils.DBE)
  408. var ActiComplete workflow.ActiCompleteVM
  409. ActiComplete.ProcessKey = activity.ProcessKey
  410. ActiComplete.BusinessKey = activity.BusinessKey
  411. ActiComplete.UserId = this.User.Id
  412. ActiComplete.Remarks = ""
  413. ActiComplete.Result = "1"
  414. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  415. fmt.Println(receiveVal)
  416. model.Status = suppliercert.STORE_STATUS
  417. model.Step = 7
  418. model.StorageOn = time.Now()
  419. model.ApplyTime = time.Now().AddDate(1, 0, 0)
  420. model.InFlag = "1"
  421. model.ModifiedOn = time.Now()
  422. model.ModifiedBy = this.User.Realname
  423. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  424. cols := []string{
  425. "Step",
  426. "Status",
  427. "ApplyTime",
  428. "InFlag",
  429. "StorageOn",
  430. "ModifiedOn",
  431. "ModifiedUserId",
  432. "ModifiedBy",
  433. }
  434. err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols)
  435. var model2 suppliercertsub.OilSupplierCertSub
  436. model2.CertSubStatus = "1"
  437. whereid := " SupplierCertId = " + id
  438. svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &model2, []string{"CertSubStatus"}, whereid)
  439. var model3 supplier.OilSupplier
  440. model3.PACNumber = PACNumber
  441. cols3 := []string{"PACNumber"}
  442. svc.UpdateEntityByIdCols(SupplierId, &model3, cols3)
  443. }
  444. if err == nil {
  445. errinfo.Message = "提交成功!"
  446. errinfo.Code = 0
  447. this.Data["json"] = &errinfo
  448. this.ServeJSON()
  449. } else {
  450. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  451. errinfo.Code = -1
  452. this.Data["json"] = &errinfo
  453. this.ServeJSON()
  454. }
  455. }
  456. // @Title 删除单条信息
  457. // @Description
  458. // @Success 200 {object} ErrorInfo
  459. // @Failure 403 :id 为空
  460. // @router /delete/:Id [delete]
  461. func (this *OilSupplierCertController) DeleteEntity() {
  462. Id := this.Ctx.Input.Param(":Id")
  463. var errinfo ErrorInfo
  464. if Id == "" {
  465. errinfo.Message = "操作失败!请求信息不完整"
  466. errinfo.Code = -2
  467. this.Data["json"] = &errinfo
  468. this.ServeJSON()
  469. return
  470. }
  471. var model suppliercert.OilSupplierCert
  472. var entityempty suppliercert.OilSupplierCert
  473. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  474. opdesc := "删除-" + Id
  475. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  476. if err == nil {
  477. errinfo.Message = "删除成功"
  478. errinfo.Code = 0
  479. this.Data["json"] = &errinfo
  480. this.ServeJSON()
  481. } else {
  482. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  483. errinfo.Code = -1
  484. this.Data["json"] = &errinfo
  485. this.ServeJSON()
  486. }
  487. }
  488. // @Title 提交审批
  489. // @Description 提交审批
  490. // @Success 200 {object} controllers.Request
  491. // @router /audit/:id [post]
  492. func (this *OilSupplierCertController) AuditEntity() {
  493. certId := this.Ctx.Input.Param(":id")
  494. firstAudit := this.GetString("FirstAuditName")
  495. AuditRemark := this.GetString("AuditRemark")
  496. secondAudit := this.GetString("SecondAudit")
  497. thirdAudit := this.GetString("ThirdAudit")
  498. typeCode := this.GetString("TypeCode")
  499. var setting auditsetting.Base_OilAuditSetting
  500. var userlist []userRole.Base_User
  501. usvc := userRole.GetUserService(utils.DBE)
  502. where := ""
  503. if this.User.IsCompanyUser == 1 {
  504. if typeCode == "01" {
  505. where = "AuditStepCode='" + workflow.SUB_OFFICE_WZ + "'"
  506. } else if typeCode == "02" {
  507. where = "AuditStepCode='" + workflow.SUB_OFFICE_JS + "'"
  508. } else if typeCode == "03" {
  509. where = "AuditStepCode='" + workflow.SUB_OFFICE_JF + "'"
  510. }
  511. usvc.GetEntity(&setting, where)
  512. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  513. tempstr := strings.Join(ids, ",")
  514. uids := strings.Replace(tempstr, "uid_", "", -1)
  515. uids = strings.Trim(uids, ",")
  516. if uids != "" {
  517. where := "Id in (" + uids + ")" + " and UnitId=" + firstAudit
  518. usvc.GetEntities(&userlist, where)
  519. }
  520. userIds := ""
  521. for _, tmpUser := range userlist {
  522. userIds += strconv.Itoa(tmpUser.Id) + ","
  523. }
  524. firstAudit = strings.Trim(userIds, ",")
  525. }
  526. //取出审批列表
  527. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  528. var supplierCertEntity suppliercert.OilSupplierCert
  529. certSrv.GetEntityById(certId, &supplierCertEntity)
  530. //取出企业主表
  531. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  532. var supplierEntity supplier.OilSupplier
  533. supplierSvc.GetEntityById(supplierCertEntity.SupplierId, &supplierEntity)
  534. svc := organize.GetOrganizeService(utils.DBE)
  535. unitId := svc.GetMyUnitDepartmentId(this.User.DepartmentId)
  536. var errinfo ErrorDataInfo
  537. defer func() { //finally处理失败的异常
  538. if err := recover(); err != nil {
  539. errinfo.Message = "提交失败," + err.(string)
  540. errinfo.Code = -1
  541. this.Data["json"] = &errinfo
  542. this.ServeJSON()
  543. } else {
  544. //返回正确结果
  545. errinfo.Message = "审核提交成功"
  546. errinfo.Code = 0
  547. this.Data["json"] = &errinfo
  548. this.ServeJSON()
  549. }
  550. }()
  551. ////判断当前部门是否企业用户
  552. //result := "1"
  553. //if this.User.IsCompanyUser == 1 {
  554. // result = "0"
  555. //}
  556. svcActiviti := workflow.GetActivitiService(utils.DBE)
  557. ////获得有审核权限的人员
  558. //var users []userRole.Base_RoleList
  559. //var userIds string
  560. //var auditWorkflow auditsetting.Base_OilAuditSetting
  561. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  562. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, firstAudit, workflow.FIRST_TRIAL, &auditWorkflow)
  563. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  564. processInstanceId := ""
  565. businessKey := ""
  566. result := strconv.Itoa(this.User.IsCompanyUser)
  567. status, _ := strconv.Atoi(supplierCertEntity.Status)
  568. if status <= 0 {
  569. //启动工作流
  570. businessKey = certId + "-" + strconv.Itoa(supplierCertEntity.AuditIndex)
  571. // 1 评审准入 2 一级物资备案准入 3 二级物资备案准入 4 战略合作准入 5 内部多元准入 6 外部市场准入
  572. if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" {
  573. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  574. } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT {
  575. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  576. } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" {
  577. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  578. } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT {
  579. // 二级物资准入(除大港油田外的其他公司)
  580. processInstanceId = svcActiviti.StartProcess2(workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  581. }
  582. } else {
  583. processInstanceId = supplierCertEntity.WorkflowId
  584. }
  585. //processInstanceId,_ := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.FIRST_TRIAL, this.User.Id, result, "提交给二级单位初审", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  586. //for _, tmpUser := range users {
  587. // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
  588. //}
  589. //userIds = strings.Trim(userIds, ",")
  590. var ActiComplete workflow.ActiCompleteVM
  591. if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" {
  592. ActiComplete.ProcessKey = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY
  593. } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT {
  594. ActiComplete.ProcessKey = workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY
  595. } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" {
  596. ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
  597. } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT {
  598. ActiComplete.ProcessKey = workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY
  599. }
  600. //if this.User.IsCompanyUser == 1 {
  601. // if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" {
  602. // ActiComplete.ProcessKey = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY
  603. // } else if supplierCertEntity.InStyle == "3" {
  604. // ActiComplete.ProcessKey = workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY
  605. // } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" {
  606. // ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
  607. // }
  608. //}else if this.User.IsCompanyUser == 0 {
  609. // if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" {
  610. // ActiComplete.ProcessKey = workflow.OIL_FIRST_SUPPLIER_APPLY
  611. // } else if supplierCertEntity.InStyle == "3" {
  612. // ActiComplete.ProcessKey = workflow.OIL_SECOND_SUPPLIER_APPLY
  613. // } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" {
  614. // ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
  615. // }
  616. //}
  617. ActiComplete.BusinessKey = businessKey
  618. ActiComplete.UserNames = firstAudit
  619. ActiComplete.UserId = this.User.Id
  620. ActiComplete.Result = result
  621. ActiComplete.Remarks = AuditRemark
  622. ActiComplete.CallbackUrl = ""
  623. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  624. var audithistoryentity audithistory.Base_AuditHistory
  625. audithistoryentity.EntityId = supplierCertEntity.Id
  626. audithistoryentity.WorkflowId = supplierCertEntity.WorkflowId
  627. audithistoryentity.Process = ActiComplete.ProcessKey
  628. audithistoryentity.BusinessKey = ActiComplete.BusinessKey
  629. audithistoryentity.Type = supplierCertEntity.SupplierTypeCode
  630. audithistoryentity.BackStep = supplierCertEntity.Status
  631. audithistoryentity.Index = supplierCertEntity.AuditIndex
  632. audithistoryentity.CreateOn = time.Now()
  633. audithistoryentity.CreateBy = this.User.Realname
  634. audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  635. certSrv.InsertEntity(audithistoryentity)
  636. if receiveVal == "true" {
  637. errinfo.Message = "提交成功!"
  638. errinfo.Code = 0
  639. this.Data["json"] = &errinfo
  640. this.ServeJSON()
  641. } else {
  642. errinfo.Message = "工作流异常,请联系管理员!"
  643. errinfo.Code = -1
  644. this.Data["json"] = &errinfo
  645. this.ServeJSON()
  646. return
  647. }
  648. fmt.Println("-----------processInstanceId------------")
  649. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  650. supplierCertEntity.WorkflowId = processInstanceId
  651. if this.User.IsCompanyUser == 1 {
  652. supplierCertEntity.Status = suppliercert.FEN_TRIAL_STATUS //分办
  653. } else if this.User.IsCompanyUser == 0 {
  654. supplierCertEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
  655. }
  656. supplierCertEntity.Step = 2
  657. supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  658. supplierCertEntity.AuditIndex = supplierCertEntity.AuditIndex + 1
  659. supplierCertEntity.BusinessKey = ActiComplete.BusinessKey
  660. supplierCertEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
  661. supplierCertEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit)
  662. supplierCertEntity.ProcessKey = ActiComplete.ProcessKey
  663. supplierCertEntity.CommitComId = unitId
  664. cols := []string{
  665. "Id",
  666. "WorkflowId",
  667. "Status",
  668. "Step",
  669. "FirstAudit",
  670. "AuditIndex",
  671. "BusinessKey",
  672. "SecondAudit",
  673. "ThirdAudit",
  674. "ProcessKey",
  675. "CommitComId",
  676. }
  677. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  678. //var model classorgsetting.OilClassOrgSetting
  679. //var jsonBlob = this.Ctx.Input.RequestBody
  680. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  681. //
  682. //json.Unmarshal(jsonBlob, &model)
  683. //model.CreateOn = time.Now()
  684. //model.CreateBy = this.User.Realname
  685. //model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  686. ////model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  687. //
  688. //svc.InsertEntityBytbl(OilSupplierCertName, &model)
  689. //fmt.Println(model)
  690. }
  691. // @Title 专业审批
  692. // @Description 准入初审提交审批
  693. // @Success 200 {object} controllers.Request
  694. // @router /admission/:id [post]
  695. func (this *OilSupplierCertController) AuditEntityadmission() {
  696. certId := this.Ctx.Input.Param(":id")
  697. var errinfo ErrorDataInfo
  698. defer func() { //finally处理失败的异常
  699. if err := recover(); err != nil {
  700. errinfo.Message = "提交失败," + err.(string)
  701. errinfo.Code = -1
  702. this.Data["json"] = &errinfo
  703. this.ServeJSON()
  704. } else {
  705. //返回正确结果
  706. errinfo.Message = "审核提交成功"
  707. errinfo.Code = 0
  708. this.Data["json"] = &errinfo
  709. this.ServeJSON()
  710. }
  711. }()
  712. //取出审批列表
  713. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  714. certSrv.SubmitOrgAudit(certId, workflow.OIL_ENUSER_SUPPLIER_APPLY, workflow.PROF_AUDIT, this.User.Id, "1", "提交给专业科室审核", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
  715. //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
  716. var supplierCertEntity suppliercert.OilSupplierCert
  717. certSrv.GetEntityById(certId, supplierCertEntity)
  718. supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //二级单位初审
  719. cols := []string{
  720. "Id",
  721. "Status",
  722. }
  723. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  724. }
  725. // @Title 审批
  726. // @Description 审批
  727. // @Param body body suppliercert.OilSupplierCert
  728. // @Success 200 {object} controllers.Request
  729. // @router /auditEntityFir/:id [post]
  730. func (this *OilSupplierCertController) AuditEntityFir() {
  731. var dataother ShenHeModel
  732. certId := this.Ctx.Input.Param(":id")
  733. auditer := this.GetString("auditer")
  734. firstAudit := this.GetString("FirstAuditName")
  735. AuditRemark := this.GetString("AuditRemark")
  736. secondAudit := this.GetString("SecondAudit")
  737. thirdAudit := this.GetString("ThirdAudit")
  738. //majorDept := this.GetString("majorDept")
  739. //取出审批列表
  740. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  741. var supplierCertEntity suppliercert.OilSupplierCert
  742. var supplierEntity supplier.OilSupplier
  743. certSrv.GetEntityById(certId, &supplierCertEntity)
  744. wheresup := "Id=" + strconv.Itoa(supplierCertEntity.SupplierId)
  745. certSrv.GetEntity(&supplierEntity, wheresup)
  746. var jsonblob = this.Ctx.Input.RequestBody
  747. json.Unmarshal(jsonblob, &dataother)
  748. if AuditRemark != "" {
  749. dataother.AuditorRemark = AuditRemark
  750. }
  751. var errinfo ErrorDataInfo
  752. defer func() { //finally处理失败的异常
  753. if err := recover(); err != nil {
  754. errinfo.Message = "提交失败," + err.(string)
  755. errinfo.Code = -1
  756. this.Data["json"] = &errinfo
  757. this.ServeJSON()
  758. } else {
  759. //返回正确结果
  760. errinfo.Message = "审核提交成功"
  761. errinfo.Code = 0
  762. this.Data["json"] = &errinfo
  763. this.ServeJSON()
  764. }
  765. }()
  766. //remarks := ""
  767. step := 2
  768. status := ""
  769. backstatus := "0"
  770. var userIds string
  771. if supplierCertEntity.Status == suppliercert.FEN_TRIAL_STATUS {
  772. userIds = firstAudit
  773. status = suppliercert.FIRST_TRIAL_STATUS
  774. backstatus = suppliercert.NO_FEN_TRIAL_STATUS
  775. step = 2
  776. if dataother.SuccessStatus == 1 {
  777. supplierCertEntity.Step = 2
  778. supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
  779. supplierCertEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
  780. supplierCertEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit)
  781. cols := []string{
  782. "Id",
  783. "Step",
  784. "FirstAudit",
  785. "SecondAudit",
  786. "ThirdAudit",
  787. }
  788. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  789. }
  790. }
  791. if supplierCertEntity.Status == suppliercert.FIRST_TRIAL_STATUS {
  792. userIds = utils.ToStr(supplierCertEntity.SecondAudit)
  793. status = suppliercert.SECOND_TRIAL_STATUS
  794. backstatus = suppliercert.NOPASS_STATUS
  795. step = 2
  796. //supplierCertEntity.ThirdAudit,_ = strconv.Atoi(majorDept)
  797. //cols := []string{
  798. // "ThirdAudit",
  799. //}
  800. //certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  801. } else if supplierCertEntity.Status == suppliercert.SECOND_TRIAL_STATUS {
  802. step = 2
  803. backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
  804. svc := organize.GetOrganizeService(utils.DBE)
  805. unitId := svc.GetMyUnitDepartmentId(strconv.Itoa(supplierCertEntity.ThirdAudit))
  806. var userlist []userRole.Base_User
  807. var setting auditsetting.Base_OilAuditSetting
  808. usvc := userRole.GetUserService(utils.DBE)
  809. if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT {
  810. status = suppliercert.THIRD_TRIAL_STATUS
  811. where := "AuditStepCode='" + workflow.PROF_RECE + "'"
  812. usvc.GetEntity(&setting, where)
  813. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  814. tempstr := strings.Join(ids, ",")
  815. uids := strings.Replace(tempstr, "uid_", "", -1)
  816. uids = strings.Trim(uids, ",")
  817. if uids != "" {
  818. where := "Id in (" + uids + ")" + " and UnitId=" + strconv.Itoa(supplierCertEntity.ThirdAudit)
  819. usvc.GetEntities(&userlist, where)
  820. }
  821. } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT {
  822. status = suppliercert.CENT_AUDIT_STATUS
  823. step = 2
  824. backstatus = suppliercert.NO_PROF_AUDIT_STATUS
  825. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  826. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  827. var userlist []userRole.Base_User
  828. var setting auditsetting.Base_OilAuditSetting
  829. usvc := userRole.GetUserService(utils.DBE)
  830. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  831. usvc.GetEntity(&setting, where)
  832. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  833. tempstr := strings.Join(ids, ",")
  834. uids := strings.Replace(tempstr, "uid_", "", -1)
  835. uids = strings.Trim(uids, ",")
  836. if uids != "" {
  837. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  838. usvc.GetEntities(&userlist, where)
  839. }
  840. for _, tmpUser := range userlist {
  841. userIds += strconv.Itoa(tmpUser.Id) + ","
  842. }
  843. userIds = strings.Trim(userIds, ",")
  844. } else if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" {
  845. svcActiviti := workflow.GetActivitiService(utils.DBE)
  846. businessKey := strconv.Itoa(supplierCertEntity.Id)
  847. result := "1"
  848. userIds := ""
  849. var userlist []userRole.Base_User
  850. var setting auditsetting.Base_OilAuditSetting
  851. usvc := userRole.GetUserService(utils.DBE)
  852. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  853. certSrv.GetEntity(&setting, where)
  854. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  855. tempstr := strings.Join(ids, ",")
  856. uids := strings.Replace(tempstr, "uid_", "", -1)
  857. uids = strings.Trim(uids, ",")
  858. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  859. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  860. if uids != "" {
  861. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  862. paramSvc.GetEntities(&userlist, where)
  863. }
  864. for _, tmpUser := range userlist {
  865. userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + ","
  866. }
  867. userIds = strings.Trim(userIds, ",")
  868. processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  869. //var ActiComplete workflow.ActiCompleteVM
  870. //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  871. //ActiComplete.BusinessKey = businessKey
  872. //ActiComplete.UserNames = userIds
  873. //ActiComplete.UserId = this.User.Id
  874. //ActiComplete.Result = "1"
  875. //ActiComplete.Remarks = ""
  876. //ActiComplete.CallbackUrl = ""
  877. //
  878. //res := svcActiviti.TaskComplete(ActiComplete)
  879. //fmt.Println(res)
  880. var activity oilactivity.OilActivity
  881. activity.EntityId = supplierCertEntity.Id
  882. activity.ActType = oilactivity.STORAGE
  883. activity.WorkflowId = processInstanceId
  884. activity.BusinessKey = businessKey
  885. activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  886. activity.CreateOn = time.Now()
  887. certSrv.InsertEntityBytbl(OilActivityName, &activity)
  888. status = suppliercert.STOREING_STATUS
  889. step = 3
  890. } else {
  891. status = suppliercert.THIRD_TRIAL_STATUS
  892. where := "AuditStepCode='" + workflow.PROF_RECE + "'"
  893. svc.GetEntity(&setting, where)
  894. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  895. tempstr := strings.Join(ids, ",")
  896. uids := strings.Replace(tempstr, "uid_", "", -1)
  897. uids = strings.Trim(uids, ",")
  898. if uids != "" {
  899. where := "Id in (" + uids + ")" + " and UnitId=" + unitId
  900. svc.GetEntities(&userlist, where)
  901. }
  902. }
  903. //var users []userRole.Base_RoleList
  904. //certSrv.GetAuditUser(strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &users)
  905. for _, tmpUser := range userlist {
  906. userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + ","
  907. }
  908. userIds = strings.Trim(userIds, ",")
  909. //step = 2
  910. //backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
  911. } else if supplierCertEntity.Status == suppliercert.THIRD_TRIAL_STATUS {
  912. userIds = auditer
  913. status = suppliercert.PROF_AUDIT_STATUS
  914. step = 2
  915. backstatus = suppliercert.NO_THIRD_TRIAL_STATUS
  916. } else if supplierCertEntity.Status == suppliercert.PROF_AUDIT_STATUS {
  917. if supplierCertEntity.InStyle == "3" {
  918. userIds = auditer
  919. status = suppliercert.PAYING_AUDIT_STATUS
  920. step = 3
  921. backstatus = suppliercert.NO_CENT_AUDIT_STATUS
  922. } else {
  923. status = suppliercert.CENT_AUDIT_STATUS
  924. step = 2
  925. backstatus = suppliercert.NO_PROF_AUDIT_STATUS
  926. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  927. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  928. var userlist []userRole.Base_User
  929. var setting auditsetting.Base_OilAuditSetting
  930. usvc := userRole.GetUserService(utils.DBE)
  931. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  932. usvc.GetEntity(&setting, where)
  933. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  934. tempstr := strings.Join(ids, ",")
  935. uids := strings.Replace(tempstr, "uid_", "", -1)
  936. uids = strings.Trim(uids, ",")
  937. if uids != "" {
  938. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  939. usvc.GetEntities(&userlist, where)
  940. }
  941. for _, tmpUser := range userlist {
  942. userIds += strconv.Itoa(tmpUser.Id) + ","
  943. }
  944. userIds = strings.Trim(userIds, ",")
  945. }
  946. } else if supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS {
  947. userIds = auditer
  948. status = suppliercert.PAYING_AUDIT_STATUS
  949. step = 3
  950. backstatus = suppliercert.NO_CENT_AUDIT_STATUS
  951. }
  952. svcActiviti := workflow.GetActivitiService(utils.DBE)
  953. var ActiComplete workflow.ActiCompleteVM
  954. ActiComplete.ProcessKey = supplierCertEntity.ProcessKey
  955. ActiComplete.BusinessKey = supplierCertEntity.BusinessKey
  956. ActiComplete.UserNames = userIds
  957. ActiComplete.UserId = this.User.Id
  958. ActiComplete.Remarks = dataother.AuditorRemark
  959. ActiComplete.CallbackUrl = ""
  960. if dataother.SuccessStatus == 1 {
  961. ActiComplete.Result = "1"
  962. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  963. if receiveVal == "true" {
  964. if supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS {
  965. if supplierCertEntity.InStyle == "1" && supplierCertEntity.IsPay == 0{
  966. paysvc := paymentinfo.GetPaymentService(utils.DBE)
  967. var Amount float64
  968. asvc := oilcostmanage.GetOilCostManageService(utils.DBE)
  969. Amount = asvc.GetAmount("ZHUNRU", supplierCertEntity.SupplierTypeCode)
  970. var payinfo paymentinfo.OilPaymentInfo
  971. payinfo.SupplierId = supplierCertEntity.SupplierId
  972. payinfo.SrcId = supplierCertEntity.Id
  973. payinfo.SupplierCertId = supplierCertEntity.Id
  974. payinfo.USCCode = supplierEntity.CommercialNo
  975. payinfo.SupplierName = supplierEntity.SupplierName
  976. payinfo.PayType = "1"
  977. payinfo.Amount = strconv.FormatFloat(Amount, 'E', -1, 64)
  978. payinfo.IsPay = "0"
  979. payinfo.IsInvoice = "0"
  980. payinfo.CreateUserId = supplierCertEntity.CreateUserId
  981. payinfo.CreateBy = supplierCertEntity.CreateBy
  982. payinfo.CreateOn = time.Now()
  983. //wheresup := " SupplierCertId=" + strconv.Itoa(supplierCertEntity.Id)
  984. //var sup []suppliercertsub.OilSupplierCertSub
  985. //total := paysvc.GetPagingEntitiesWithOrder(1, 10, "Id", true, &sup, wheresup)
  986. //if supplierCertEntity.SupplierTypeCode == "01" && total <= 50 {
  987. // status = suppliercert.STOREING_STATUS
  988. //
  989. // svcActiviti := workflow.GetActivitiService(utils.DBE)
  990. // businessKey := strconv.Itoa(supplierCertEntity.Id)
  991. // result := "1"
  992. //
  993. // userIds := ""
  994. // var userlist []userRole.Base_User
  995. // var setting auditsetting.Base_OilAuditSetting
  996. // usvc := userRole.GetUserService(utils.DBE)
  997. // where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  998. // paysvc.GetEntity(&setting, where)
  999. // ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1000. // tempstr := strings.Join(ids, ",")
  1001. // uids := strings.Replace(tempstr, "uid_", "", -1)
  1002. // uids = strings.Trim(uids, ",")
  1003. // paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1004. // topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  1005. // if uids != "" {
  1006. // where := "Id in (" + uids + ")" + " and UnitId=" + topid
  1007. // paramSvc.GetEntities(&userlist, where)
  1008. // }
  1009. //
  1010. // for _, tmpUser := range userlist {
  1011. // userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + ","
  1012. // }
  1013. // userIds = strings.Trim(userIds, ",")
  1014. //
  1015. // processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  1016. //
  1017. // //var ActiComplete workflow.ActiCompleteVM
  1018. // //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1019. // //ActiComplete.BusinessKey = businessKey
  1020. // //ActiComplete.UserNames = userIds
  1021. // //ActiComplete.UserId = this.User.Id
  1022. // //ActiComplete.Result = "1"
  1023. // //ActiComplete.Remarks = ""
  1024. // //ActiComplete.CallbackUrl = ""
  1025. // //
  1026. // //res := svcActiviti.TaskComplete(ActiComplete)
  1027. // //fmt.Println(res)
  1028. //
  1029. // var activity oilactivity.OilActivity
  1030. // activity.EntityId = supplierCertEntity.Id
  1031. // activity.ActType = oilactivity.STORAGE
  1032. // activity.WorkflowId = processInstanceId
  1033. // activity.BusinessKey = businessKey
  1034. // activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1035. // activity.CreateOn = time.Now()
  1036. //
  1037. // paysvc.InsertEntityBytbl(OilActivityName, &activity)
  1038. //
  1039. //} else {
  1040. // paysvc.InsertEntity(&payinfo)
  1041. // //发短信
  1042. // toMobile := supplierEntity.Mobile
  1043. // msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核通过,请及时确认交费信息!"
  1044. // msgService := msg2.GetMsgService(utils.DBE)
  1045. // msgService.HandleMsg(toMobile, msg, "3-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username)
  1046. //}
  1047. paysvc.InsertEntity(&payinfo)
  1048. //发短信
  1049. toMobile := supplierEntity.Mobile
  1050. msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核通过,请及时确认交费信息!"
  1051. msgService := msg2.GetMsgService(utils.DBE)
  1052. msgService.HandleMsg(toMobile, msg, "3-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username)
  1053. //paysvc.AddPaymentinfo(supplierCertEntity.SupplierId, supplierCertEntity.Id, Amount, "1")
  1054. supplierCertEntity.Status = status
  1055. supplierCertEntity.Step = step
  1056. cols := []string{
  1057. "Status",
  1058. "Step",
  1059. }
  1060. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1061. } else {
  1062. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1063. businessKey := strconv.Itoa(supplierCertEntity.Id)
  1064. result := "1"
  1065. userIds := ""
  1066. var userlist []userRole.Base_User
  1067. var setting auditsetting.Base_OilAuditSetting
  1068. usvc := userRole.GetUserService(utils.DBE)
  1069. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  1070. certSrv.GetEntity(&setting, where)
  1071. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1072. tempstr := strings.Join(ids, ",")
  1073. uids := strings.Replace(tempstr, "uid_", "", -1)
  1074. uids = strings.Trim(uids, ",")
  1075. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1076. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  1077. if uids != "" {
  1078. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  1079. paramSvc.GetEntities(&userlist, where)
  1080. }
  1081. for _, tmpUser := range userlist {
  1082. userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + ","
  1083. }
  1084. userIds = strings.Trim(userIds, ",")
  1085. processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  1086. //var ActiComplete workflow.ActiCompleteVM
  1087. //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1088. //ActiComplete.BusinessKey = businessKey
  1089. //ActiComplete.UserNames = userIds
  1090. //ActiComplete.UserId = this.User.Id
  1091. //ActiComplete.Result = "1"
  1092. //ActiComplete.Remarks = ""
  1093. //ActiComplete.CallbackUrl = ""
  1094. //
  1095. //res := svcActiviti.TaskComplete(ActiComplete)
  1096. //fmt.Println(res)
  1097. var activity oilactivity.OilActivity
  1098. activity.EntityId = supplierCertEntity.Id
  1099. activity.ActType = oilactivity.STORAGE
  1100. activity.WorkflowId = processInstanceId
  1101. activity.BusinessKey = businessKey
  1102. activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1103. activity.CreateOn = time.Now()
  1104. certSrv.InsertEntityBytbl(OilActivityName, &activity)
  1105. supplierCertEntity.Status = suppliercert.STOREING_STATUS
  1106. supplierCertEntity.Step = step
  1107. cols := []string{
  1108. "Status",
  1109. "Step",
  1110. }
  1111. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1112. }
  1113. } else if supplierCertEntity.Status == suppliercert.PROF_AUDIT_STATUS && supplierCertEntity.InStyle == "3" {
  1114. //if supplierCertEntity.InStyle == "3" {
  1115. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1116. businessKey := strconv.Itoa(supplierCertEntity.Id)
  1117. result := "1"
  1118. userIds := ""
  1119. var userlist []userRole.Base_User
  1120. var setting auditsetting.Base_OilAuditSetting
  1121. usvc := userRole.GetUserService(utils.DBE)
  1122. where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
  1123. certSrv.GetEntity(&setting, where)
  1124. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1125. tempstr := strings.Join(ids, ",")
  1126. uids := strings.Replace(tempstr, "uid_", "", -1)
  1127. uids = strings.Trim(uids, ",")
  1128. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1129. topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
  1130. if uids != "" {
  1131. where := "Id in (" + uids + ")" + " and UnitId=" + topid
  1132. paramSvc.GetEntities(&userlist, where)
  1133. }
  1134. for _, tmpUser := range userlist {
  1135. userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + ","
  1136. }
  1137. userIds = strings.Trim(userIds, ",")
  1138. processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
  1139. //var ActiComplete workflow.ActiCompleteVM
  1140. //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1141. //ActiComplete.BusinessKey = businessKey
  1142. //ActiComplete.UserNames = userIds
  1143. //ActiComplete.UserId = this.User.Id
  1144. //ActiComplete.Result = "1"
  1145. //ActiComplete.Remarks = ""
  1146. //ActiComplete.CallbackUrl = ""
  1147. //
  1148. //res := svcActiviti.TaskComplete(ActiComplete)
  1149. //fmt.Println(res)
  1150. var activity oilactivity.OilActivity
  1151. activity.EntityId = supplierCertEntity.Id
  1152. activity.ActType = oilactivity.STORAGE
  1153. activity.WorkflowId = processInstanceId
  1154. activity.BusinessKey = businessKey
  1155. activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE
  1156. activity.CreateOn = time.Now()
  1157. certSrv.InsertEntityBytbl(OilActivityName, &activity)
  1158. supplierCertEntity.Status = suppliercert.STOREING_STATUS
  1159. supplierCertEntity.Step = 3
  1160. cols := []string{
  1161. "Status",
  1162. "Step",
  1163. }
  1164. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1165. } else {
  1166. supplierCertEntity.Status = status
  1167. supplierCertEntity.Step = step
  1168. cols := []string{
  1169. "Status",
  1170. "Step",
  1171. }
  1172. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1173. }
  1174. errinfo.Message = "提交成功!"
  1175. errinfo.Code = 0
  1176. this.Data["json"] = &errinfo
  1177. this.ServeJSON()
  1178. } else {
  1179. errinfo.Message = "工作流异常,请联系管理员!"
  1180. errinfo.Code = -1
  1181. this.Data["json"] = &errinfo
  1182. this.ServeJSON()
  1183. return
  1184. }
  1185. } else {
  1186. ActiComplete.Result = "0"
  1187. receiveVal := svcActiviti.TaskComplete(ActiComplete)
  1188. if receiveVal == "true" {
  1189. // 审批历史
  1190. //var audithistoryentity audithistory.Base_AuditHistory
  1191. //audithistoryentity.EntityId = supplierCertEntity.Id
  1192. //audithistoryentity.WorkflowId = supplierCertEntity.WorkflowId
  1193. //audithistoryentity.Process = ActiComplete.ProcessKey
  1194. //audithistoryentity.BusinessKey = ActiComplete.BusinessKey
  1195. //audithistoryentity.Type = supplierCertEntity.SupplierTypeCode
  1196. //audithistoryentity.BackStep = supplierCertEntity.Status
  1197. //audithistoryentity.Index = supplierCertEntity.AuditIndex
  1198. //audithistoryentity.CreateOn = time.Now()
  1199. //audithistoryentity.CreateBy = this.User.Realname
  1200. //audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1201. //certSrv.InsertEntity(audithistoryentity)
  1202. if supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS {
  1203. supplierCertEntity.Status = suppliercert.NO_CENT_AUDIT_STATUS
  1204. supplierCertEntity.BackReason = dataother.AuditorRemark
  1205. cols := []string{
  1206. "BackReason",
  1207. }
  1208. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1209. } else {
  1210. supplierCertEntity.Status = backstatus
  1211. }
  1212. supplierCertEntity.Step = 1
  1213. //supplierCertEntity.WorkflowId = ""
  1214. cols := []string{
  1215. "Status",
  1216. "Step",
  1217. //"WorkflowId",
  1218. }
  1219. certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
  1220. toMobile := supplierEntity.Mobile
  1221. msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核未通过,请及时查看!"
  1222. msgService := msg2.GetMsgService(utils.DBE)
  1223. msgService.HandleMsg(toMobile, msg, "4-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username)
  1224. errinfo.Message = "提交成功!"
  1225. errinfo.Code = 0
  1226. this.Data["json"] = &errinfo
  1227. this.ServeJSON()
  1228. } else {
  1229. errinfo.Message = "工作流异常,请联系管理员!"
  1230. errinfo.Code = -1
  1231. this.Data["json"] = &errinfo
  1232. this.ServeJSON()
  1233. return
  1234. }
  1235. }
  1236. }
  1237. // @Title 审核
  1238. // @Description 审核
  1239. // @Success 200 {object} controllers.Request
  1240. // @router /auditcallback [get]
  1241. func (this *OilSupplierCertController) AuditCallback() {
  1242. id := this.GetString("Id")
  1243. status := this.GetString("status")
  1244. step := this.GetString("step")
  1245. var supplierCertEntity suppliercert.OilSupplierCert
  1246. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1247. supplierCertEntity.Status = status
  1248. supplierCertEntity.Step, _ = strconv.Atoi(step)
  1249. cols := []string{
  1250. "Id",
  1251. "Status",
  1252. "step",
  1253. }
  1254. svc.UpdateEntityByIdCols(id, supplierCertEntity, cols)
  1255. fmt.Println(id, status, step)
  1256. }
  1257. // @Title 获取实体
  1258. // @Description 获取实体
  1259. // @Success 200 {object} controllers.Request
  1260. // @router /isaccess [get]
  1261. func (this *OilSupplierCertController) IsAccess() {
  1262. auditstepcode := this.GetString("auditstepcode")
  1263. processkey := this.GetString("processkey")
  1264. id := this.GetString("id")
  1265. //var users []userRole.Base_RoleList
  1266. //var auditWorkflow auditsetting.Base_OilAuditSetting
  1267. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1268. res := false
  1269. if auditstepcode == workflow.PROF_CONCENT { // 集中审批
  1270. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.PROF_AUDIT, &auditWorkflow)
  1271. //users = rsvc.GetUserByRole("10000204", this.User.AccCode)
  1272. //for _, user := range users {
  1273. // if this.User.Id == strconv.Itoa(int(user.Id)) {
  1274. // res = true
  1275. // break
  1276. // }
  1277. //}
  1278. var setting auditsetting.Base_OilAuditSetting
  1279. svc := organize.GetOrganizeService(utils.DBE)
  1280. where := "AuditStepCode='" + auditstepcode + "'"
  1281. svc.GetEntity(&setting, where)
  1282. res = svc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId))
  1283. } else {
  1284. //var users []suppliercert.UserList
  1285. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + auditstepcode + "'"
  1286. //rsvc.GetEntitysByWhere(OilAuditSettingName,where, &users)
  1287. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, auditstepcode, &auditWorkflow)
  1288. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode)
  1289. //var users []userRole.Base_RoleList
  1290. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1291. //certSrv.GetAuditUser(this.User.DepartmentId, auditstepcode, &users)
  1292. var setting auditsetting.Base_OilAuditSetting
  1293. svc := organize.GetOrganizeService(utils.DBE)
  1294. where := "AuditStepCode='" + auditstepcode + "'"
  1295. svc.GetEntity(&setting, where)
  1296. res = svc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId))
  1297. if res {
  1298. actisvc := workflow.GetActivitiService(utils.DBE)
  1299. ids := actisvc.GetMyTasks(processkey, this.User.Id)
  1300. res = strings.Contains(ids, id)
  1301. }
  1302. //for _, user := range users {
  1303. // if this.User.Id == strconv.Itoa(int(user.Id)) {
  1304. // res = true
  1305. // break
  1306. // }
  1307. //}
  1308. }
  1309. this.Data["json"] = res
  1310. this.ServeJSON()
  1311. }
  1312. // @Title 获取准入编码
  1313. // @Description 获取准入编码
  1314. // @Success 200 {object} controllers.Request
  1315. // @router /createaccesscardno/:type [get]
  1316. func (this *OilSupplierCertController) CreateAccessCardNo() {
  1317. Id := this.GetString("Id")
  1318. certId := this.GetString(("SupplierCertId"))
  1319. typeCode := this.Ctx.Input.Param(":type")
  1320. codecSvc := codecsequence.GetCodecSequenceService(utils.DBE)
  1321. var entitycert suppliercert.OilSupplierCert
  1322. var entity supplier.OilSupplier
  1323. //where := "Id = " + Id
  1324. //codecSvc.GetEntities(&model, "")
  1325. seqStr := ""
  1326. cols := []string{}
  1327. if (typeCode == "01") { // 物质
  1328. has := true
  1329. for has {
  1330. seqStr = codecSvc.GetWZAccessCardNo(this.User.AccCode)
  1331. where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'"
  1332. has = codecSvc.GetEntity(&entitycert, where)
  1333. }
  1334. cols = []string{"WZAccessCardNo"}
  1335. entity.WZAccessCardNo = seqStr
  1336. } else if typeCode == "03" { //技术服务
  1337. has := true
  1338. for has {
  1339. seqStr = codecSvc.GetJFAccessCardNo(this.User.AccCode)
  1340. where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'"
  1341. has = codecSvc.GetEntity(&entitycert, where)
  1342. }
  1343. cols = []string{"JFAccessCardNo"}
  1344. entity.JFAccessCardNo = seqStr
  1345. } else if typeCode == "02" { // 基建
  1346. has := true
  1347. for has {
  1348. seqStr = codecSvc.GetJSAccessCardNo(this.User.AccCode)
  1349. where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'"
  1350. has = codecSvc.GetEntity(&entitycert, where)
  1351. }
  1352. cols = []string{"JSAccessCardNo"}
  1353. entity.JSAccessCardNo = seqStr
  1354. }
  1355. codecSvc.UpdateEntityByIdCols(Id, &entity, cols)
  1356. var cert suppliercert.OilSupplierCert
  1357. certcols := []string{"AccessCardNo"}
  1358. cert.AccessCardNo = seqStr
  1359. codecSvc.UpdateEntityByIdCols(certId, &cert, certcols)
  1360. this.Data["json"] = seqStr
  1361. this.ServeJSON()
  1362. }
  1363. // @Title 修改准入标识
  1364. // @Description 修改准入标识
  1365. // @Success 200 {object} controllers.Request
  1366. // @router /updatainflag/ [get]
  1367. func (this *OilSupplierCertController) UpdataInFlag() {
  1368. t := time.Now()
  1369. session := utils.DBE.NewSession()
  1370. var certentitys []suppliercert.OilSupplierCert
  1371. svc := suppliercert.GetOilSupplierCertSession(session)
  1372. defer func() {
  1373. session.Close()
  1374. }()
  1375. err := session.Begin()
  1376. svc.GetEntities(&certentitys, "InFlag!='3'")
  1377. currenttime := time.Now()
  1378. //.Format("2006-01-02")
  1379. for i := 0; i < len(certentitys); i++ {
  1380. if currenttime.After(certentitys[i].ApplyTime) && !currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) && certentitys[i].InFlag != "2" {
  1381. var certentity suppliercert.OilSupplierCert
  1382. certentity.InFlag = "2"
  1383. cols := []string{"InFlag"}
  1384. _, err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
  1385. if err != nil {
  1386. session.Rollback()
  1387. }
  1388. }
  1389. if currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) {
  1390. fmt.Println(time.Now().Format("2006-01-02"), certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02"))
  1391. var certentity suppliercert.OilSupplierCert
  1392. certentity.InFlag = "3"
  1393. cols := []string{"InFlag"}
  1394. _, err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
  1395. if err != nil {
  1396. session.Rollback()
  1397. }
  1398. }
  1399. }
  1400. err = session.Commit()
  1401. fmt.Println(err)
  1402. elapsed := time.Since(t)
  1403. fmt.Println(elapsed, "更新准入标识")
  1404. }
  1405. // @Title 退回
  1406. // @Description
  1407. // @Success 200 {object} controllers.Request
  1408. // @router /backstatus/:Id [post]
  1409. func (this *OilSupplierCertController) BackStatus() {
  1410. id := this.Ctx.Input.Param(":Id")
  1411. status := this.GetString("Status")
  1412. backRemark := this.GetString("BackRemark")
  1413. var entity suppliercert.OilSupplierCert
  1414. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1415. cols := []string{"Status", "BackRemark"}
  1416. entity.Status = status
  1417. entity.BackRemark = backRemark
  1418. _, err := svc.UpdateEntityByIdCols(id, &entity, cols)
  1419. var errinfo ErrorDataInfo
  1420. if err == nil {
  1421. var activity oilactivity.OilActivity
  1422. where := "EntityId=" + id + " and ActType='" + oilactivity.STORAGE + "'"
  1423. svc.GetEntity(&activity, where)
  1424. svcActiviti := workflow.GetActivitiService(utils.DBE)
  1425. var ActiComplete workflow.ActiCompleteVM
  1426. ActiComplete.ProcessKey = activity.ProcessKey
  1427. ActiComplete.BusinessKey = activity.BusinessKey
  1428. ActiComplete.UserId = this.User.Id
  1429. ActiComplete.Remarks = ""
  1430. ActiComplete.Result = "1"
  1431. svcActiviti.TaskComplete(ActiComplete)
  1432. errinfo.Message = "操作成功!"
  1433. errinfo.Code = 00
  1434. this.Data["json"] = &errinfo
  1435. this.ServeJSON()
  1436. } else {
  1437. errinfo.Message = "操作失败!"
  1438. errinfo.Code = -1
  1439. this.Data["json"] = &errinfo
  1440. this.ServeJSON()
  1441. }
  1442. }
  1443. // @Title 保存准入编码
  1444. // @Description 保存准入编码
  1445. // @Success 200 {object} controllers.Request
  1446. // @router /saveaccesscardno/:Id [get]
  1447. func (this *OilSupplierCertController) SaveAccessCardNo() {
  1448. id := this.Ctx.Input.Param(":Id")
  1449. certId := this.GetString(("SupplierCertId"))
  1450. typeCode := this.GetString("typeCode")
  1451. accessCardNo := this.GetString("AccessCardNo")
  1452. var model []suppliercert.OilSupplierCert
  1453. var supplier supplier.OilSupplier
  1454. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1455. where := "AccessCardNo='" + accessCardNo + "'"
  1456. svc.GetEntities(&model, where)
  1457. supcols := []string{}
  1458. if model == nil || len(model) == 0 {
  1459. if (typeCode == "01") { // 物质
  1460. supplier.WZAccessCardNo = accessCardNo
  1461. supcols = []string{"WZAccessCardNo"}
  1462. } else if typeCode == "03" { //技术服务
  1463. supplier.JFAccessCardNo = accessCardNo
  1464. supcols = []string{"JFAccessCardNo"}
  1465. } else if typeCode == "02" { // 基建
  1466. supplier.JSAccessCardNo = accessCardNo
  1467. supcols = []string{"JSAccessCardNo"}
  1468. }
  1469. svc.UpdateEntityByIdCols(id, &supplier, supcols)
  1470. var cert suppliercert.OilSupplierCert
  1471. certcols := []string{"AccessCardNo"}
  1472. cert.AccessCardNo = accessCardNo
  1473. svc.UpdateEntityByIdCols(certId, &cert, certcols)
  1474. var errinfo ErrorDataInfo
  1475. errinfo.Message = "保存成功!"
  1476. errinfo.Code = 0
  1477. this.Data["json"] = &errinfo
  1478. this.ServeJSON()
  1479. } else {
  1480. var errinfo ErrorDataInfo
  1481. errinfo.Message = "准入编码已经存在!"
  1482. errinfo.Code = -1
  1483. this.Data["json"] = &errinfo
  1484. this.ServeJSON()
  1485. }
  1486. }
  1487. // @Title 快到期短信通知
  1488. // @Description 修改准入标识
  1489. // @Success 200 {object} controllers.Request
  1490. // @router /sendingSMS/ [get]
  1491. func (this *OilSupplierCertController) SendingSMS() {
  1492. t := time.Now()
  1493. svcsupp := supplier.GetOilSupplierService(utils.DBE)
  1494. var list []supplier.OilSupplierView
  1495. where := "b.InFlag = '1'"
  1496. svcsupp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 0, 0, "Id", true, &list, where)
  1497. currenttime := time.Now()
  1498. loginName := "TimingTask"
  1499. if this.User != nil {
  1500. loginName = this.User.Username
  1501. }
  1502. for _, item := range list {
  1503. if currenttime.AddDate(0, 3, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
  1504. toMobile := item.Mobile
  1505. msg := "您的" + item.SupplierTypeName + "准入还有3个月到期"
  1506. msgService := msg2.GetMsgService(utils.DBE)
  1507. msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
  1508. }
  1509. if currenttime.AddDate(0, 2, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
  1510. toMobile := item.Mobile
  1511. msg := "您的" + item.SupplierTypeName + "准入还有2个月到期"
  1512. msgService := msg2.GetMsgService(utils.DBE)
  1513. msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
  1514. }
  1515. if currenttime.AddDate(0, 1, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
  1516. toMobile := item.Mobile
  1517. msg := "您的" + item.SupplierTypeName + "准入还有1个月到期"
  1518. msgService := msg2.GetMsgService(utils.DBE)
  1519. msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
  1520. }
  1521. }
  1522. elapsed := time.Since(t)
  1523. fmt.Println(elapsed, "快到期提醒")
  1524. }
  1525. // @Title 资质快到期短信通知
  1526. // @Description
  1527. // @Success 200 {object} controllers.Request
  1528. // @router /sendingSMSSupplierFile/ [get]
  1529. func (this *OilSupplierCertController) SendingSMSSupplierFile() {
  1530. t := time.Now()
  1531. svcsupp := supplier.GetOilSupplierService(utils.DBE)
  1532. var expireFile []supplier.ExpireFile
  1533. where := " b.EffectDate LIKE '%" + time.Now().AddDate(0, 1, 0).Format("2006-01-02") + "%'"
  1534. err := svcsupp.GetExpireFile(OilSupplierName, OilSupplierFileName, &expireFile, where)
  1535. if err == nil {
  1536. for _, item := range expireFile {
  1537. fileName := ""
  1538. if utf8.RuneCountInString(item.NeedAllFile) > 50 {
  1539. fileName = string([]rune(item.NeedAllFile)[0: 50])
  1540. fileName = fileName[0: strings.LastIndex(fileName, ";")] + "等资质"
  1541. } else {
  1542. fileName = item.NeedAllFile
  1543. }
  1544. toMobile := item.Mobile
  1545. msg := "您的" + fileName + "还有1个月到期"
  1546. msgService := msg2.GetMsgService(utils.DBE)
  1547. loginName := "TimingTask"
  1548. if this.User != nil {
  1549. loginName = this.User.Username
  1550. }
  1551. msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
  1552. }
  1553. }
  1554. elapsed := time.Since(t)
  1555. fmt.Println(elapsed, "资质到期提醒")
  1556. }
  1557. // @Title 资质
  1558. // @Description
  1559. // @Success 200 {object} controllers.Request
  1560. // @router /changeSupplierStatus/ [get]
  1561. func (this *OilSupplierCertController) ChangeSupplierStatus() {
  1562. svcsupp := supplier.GetOilSupplierService(utils.DBE)
  1563. var fileData []supplier.ExpireFileList
  1564. where := " b.EffectDate LIKE '%" + time.Now().AddDate(0, 0, -1).Format("2006-01-02") + "%'"
  1565. svcsupp.GetExpireFileList(OilSupplierName, OilSupplierFileName, &fileData, where)
  1566. for _, item := range fileData {
  1567. var sert suppliercert.OilSupplierCert
  1568. cols := []string{
  1569. "InFlag",
  1570. }
  1571. sert.InFlag = "2"
  1572. where := "SupplierId=" + strconv.Itoa(item.Id) + " AND InFlag = '1'"
  1573. if item.SupplierTypeCode != "000" {
  1574. where = where + " and SupplierTypeCode='" + item.SupplierTypeCode +"'"
  1575. }
  1576. svcsupp.UpdateEntityBywheretbl(OilSupplierCertName, &sert, cols, where)
  1577. }
  1578. }
  1579. // @Title 更新Inflag状态
  1580. // @Description 企业入库
  1581. // @Success 200 {object} controllers.Request
  1582. // @router /reinput/:id [post]
  1583. func (this *OilSupplierCertController) ReInput() {
  1584. id := this.Ctx.Input.Param(":id")
  1585. var errinfo ErrorInfo
  1586. if id == "" {
  1587. errinfo.Message = "操作失败!请求信息不完整"
  1588. errinfo.Code = -2
  1589. this.Data["json"] = &errinfo
  1590. this.ServeJSON()
  1591. return
  1592. }
  1593. session := utils.DBE.NewSession()
  1594. svc := suppliercert.GetOilSupplierCertSession(session)
  1595. defer func() {
  1596. session.Close()
  1597. }()
  1598. err := session.Begin()
  1599. var model []suppliercert.Del_OilSupplierCert
  1600. where := "SupplierId=" + id
  1601. var sql string
  1602. sql = "select * from " + OilSupplierCertName + " where " + where
  1603. utils.DBE.SQL(sql).Find(&model)
  1604. isdelsupplier := false
  1605. if model != nil && len(model) > 0 {
  1606. isdelsupplier = true
  1607. }
  1608. for _, item := range model {
  1609. if item.InFlag == "3" {
  1610. where := "Id=" + strconv.Itoa(item.Id)
  1611. err = svc.DeleteEntityBytbl(OilSupplierCertName, where)
  1612. if err != nil {
  1613. session.Rollback()
  1614. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1615. errinfo.Code = -1
  1616. this.Data["json"] = &errinfo
  1617. this.ServeJSON()
  1618. return
  1619. }
  1620. item.DeleteDate = time.Now()
  1621. _, err = svc.InsertEntityBytbl(DelOilSupplierCertName, &item)
  1622. if err != nil {
  1623. session.Rollback()
  1624. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1625. errinfo.Code = -1
  1626. this.Data["json"] = &errinfo
  1627. this.ServeJSON()
  1628. return
  1629. }
  1630. // 交费信息
  1631. var delpay []paymentinfo.Del_OilPaymentInfo
  1632. wherepay := "SupplierCertId=" + strconv.Itoa(model[0].Id)
  1633. var sqlpay string
  1634. sqlpay = "select * from " + OilPaymentInfoName + " where " + wherepay
  1635. utils.DBE.SQL(sqlpay).Find(&delpay)
  1636. err = svc.DeleteEntityBytbl(OilPaymentInfoName, wherepay)
  1637. if err != nil {
  1638. session.Rollback()
  1639. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1640. errinfo.Code = -1
  1641. this.Data["json"] = &errinfo
  1642. this.ServeJSON()
  1643. return
  1644. }
  1645. for idx, _ := range delpay {
  1646. delpay[idx].DeleteDate = time.Now()
  1647. }
  1648. _, err = svc.InsertEntityBytbl(DelOilPaymentInfoName, &delpay)
  1649. if err != nil {
  1650. session.Rollback()
  1651. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1652. errinfo.Code = -1
  1653. this.Data["json"] = &errinfo
  1654. this.ServeJSON()
  1655. return
  1656. }
  1657. // 删除增项记录
  1658. var modelapp []suppliercertappend.Del_OilSupplierCertAppend
  1659. whereapp := "SupplierCertId=" + strconv.Itoa(model[0].Id)
  1660. var sqlapp string
  1661. sqlapp = "select * from " + OilSupplierCertAppendName + " where " + whereapp
  1662. utils.DBE.SQL(sqlapp).Find(&modelapp)
  1663. err = svc.DeleteEntityBytbl(OilSupplierCertAppendName, whereapp)
  1664. if err != nil {
  1665. session.Rollback()
  1666. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1667. errinfo.Code = -1
  1668. this.Data["json"] = &errinfo
  1669. this.ServeJSON()
  1670. return
  1671. }
  1672. for idx, _ := range modelapp {
  1673. modelapp[idx].DeleteDate = time.Now()
  1674. }
  1675. _, err = svc.InsertEntityBytbl(DelOilSupplierCertAppendName, &modelapp)
  1676. if err != nil {
  1677. session.Rollback()
  1678. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1679. errinfo.Code = -1
  1680. this.Data["json"] = &errinfo
  1681. this.ServeJSON()
  1682. return
  1683. }
  1684. // 删除年审记录
  1685. var modelann []annualaudit.Del_OilAnnualAudit
  1686. whereann := "CerId=" + strconv.Itoa(model[0].Id)
  1687. var sqlann string
  1688. sqlann = "select * from " + OilAnnualAuditName + " where " + whereann
  1689. utils.DBE.SQL(sqlann).Find(&modelann)
  1690. err = svc.DeleteEntityBytbl(OilAnnualAuditName, whereann)
  1691. if err != nil {
  1692. session.Rollback()
  1693. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1694. errinfo.Code = -1
  1695. this.Data["json"] = &errinfo
  1696. this.ServeJSON()
  1697. return
  1698. }
  1699. for idx, _ := range modelann {
  1700. modelann[idx].DeleteDate = time.Now()
  1701. }
  1702. _, err = svc.InsertEntityBytbl(DelOilAnnualAuditName, &modelann)
  1703. if err != nil {
  1704. session.Rollback()
  1705. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1706. errinfo.Code = -1
  1707. this.Data["json"] = &errinfo
  1708. this.ServeJSON()
  1709. return
  1710. }
  1711. // 删除准入范围
  1712. var certsup []suppliercertsub.Del_OilSupplierCertSub
  1713. wheresup := "SupplierCertId=" + strconv.Itoa(model[0].Id)
  1714. var sqlsup string
  1715. sqlsup = "select * from " + OilSupplierCertSubName + " where " + wheresup
  1716. utils.DBE.SQL(sqlsup).Find(&certsup)
  1717. err = svc.DeleteEntityBytbl(OilSupplierCertSubName, wheresup)
  1718. if err != nil {
  1719. session.Rollback()
  1720. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1721. errinfo.Code = -1
  1722. this.Data["json"] = &errinfo
  1723. this.ServeJSON()
  1724. return
  1725. }
  1726. for idx, _ := range certsup {
  1727. certsup[idx].DeleteDate = time.Now()
  1728. }
  1729. _, err = svc.InsertEntityBytbl(DelOilSupplierCertSubName, &certsup)
  1730. if err != nil {
  1731. session.Rollback()
  1732. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1733. errinfo.Code = -1
  1734. this.Data["json"] = &errinfo
  1735. this.ServeJSON()
  1736. return
  1737. }
  1738. } else {
  1739. isdelsupplier = false
  1740. }
  1741. }
  1742. if isdelsupplier {
  1743. // 删除企业信息
  1744. var modelsupp supplier.Del_OilSupplier
  1745. where := "Id=" + strconv.Itoa(model[0].SupplierId)
  1746. var sql string
  1747. sql = "select * from " + OilSupplierName + " where " + where
  1748. utils.DBE.SQL(sql).Get(&modelsupp)
  1749. err = svc.DeleteEntityBytbl(OilSupplierName, where)
  1750. if err != nil {
  1751. session.Rollback()
  1752. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1753. errinfo.Code = -1
  1754. this.Data["json"] = &errinfo
  1755. this.ServeJSON()
  1756. return
  1757. }
  1758. modelsupp.DeleteDate = time.Now()
  1759. _, err = svc.InsertEntityBytbl(DelOilSupplierName, &modelsupp)
  1760. if err != nil {
  1761. session.Rollback()
  1762. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1763. errinfo.Code = -1
  1764. this.Data["json"] = &errinfo
  1765. this.ServeJSON()
  1766. return
  1767. }
  1768. // 删除企业资质
  1769. var delfile []supplierfile.Del_OilSupplierFile
  1770. wheref := "SupplierId=" + strconv.Itoa(model[0].SupplierId)
  1771. var sqlw string
  1772. sqlw = "select * from " + OilSupplierFileName + " where " + wheref
  1773. utils.DBE.SQL(sqlw).Find(&delfile)
  1774. err = svc.DeleteEntityBytbl(OilSupplierFileName, wheref)
  1775. if err != nil {
  1776. session.Rollback()
  1777. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1778. errinfo.Code = -1
  1779. this.Data["json"] = &errinfo
  1780. this.ServeJSON()
  1781. return
  1782. }
  1783. for idx, _ := range delfile {
  1784. delfile[idx].DeleteDate = time.Now()
  1785. }
  1786. _, err = svc.InsertEntityBytbl(DelOilSupplierFileName, &delfile)
  1787. if err != nil {
  1788. session.Rollback()
  1789. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1790. errinfo.Code = -1
  1791. this.Data["json"] = &errinfo
  1792. this.ServeJSON()
  1793. return
  1794. }
  1795. // 删除信息变更
  1796. var delinfo []infochange.Del_OilInfoChange
  1797. whereinfo := "SupplierId=" + strconv.Itoa(model[0].SupplierId)
  1798. var sqlinfo string
  1799. sqlinfo = "select * from " + OilInfoChangeName + " where " + whereinfo
  1800. utils.DBE.SQL(sqlinfo).Find(&delinfo)
  1801. err = svc.DeleteEntityBytbl(OilInfoChangeName, whereinfo)
  1802. if err != nil {
  1803. session.Rollback()
  1804. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1805. errinfo.Code = -1
  1806. this.Data["json"] = &errinfo
  1807. this.ServeJSON()
  1808. return
  1809. }
  1810. for idx, _ := range delinfo {
  1811. delinfo[idx].DeleteDate = time.Now()
  1812. }
  1813. _, err = svc.InsertEntityBytbl(DelOilInfoChangeName, &delinfo)
  1814. if err != nil {
  1815. session.Rollback()
  1816. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1817. errinfo.Code = -1
  1818. this.Data["json"] = &errinfo
  1819. this.ServeJSON()
  1820. return
  1821. }
  1822. }
  1823. err = session.Commit()
  1824. if err == nil {
  1825. errinfo.Message = "提交成功!"
  1826. errinfo.Code = 0
  1827. this.Data["json"] = &errinfo
  1828. this.ServeJSON()
  1829. } else {
  1830. errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error())
  1831. errinfo.Code = -1
  1832. this.Data["json"] = &errinfo
  1833. this.ServeJSON()
  1834. }
  1835. }
  1836. // @Title 修改年审到期时间
  1837. // @Description 修改年审到期时间
  1838. // @Success 200 {object} controllers.Request
  1839. // @router /updataapplytime/:id [post]
  1840. func (this *OilSupplierCertController) UpdataApplyTime() {
  1841. session := utils.DBE.NewSession()
  1842. defer func() {
  1843. session.Close()
  1844. }()
  1845. id := this.Ctx.Input.Param(":id")
  1846. var errinfo ErrorInfo
  1847. if id == "" {
  1848. errinfo.Message = "操作失败!请求信息不完整"
  1849. errinfo.Code = -2
  1850. this.Data["json"] = &errinfo
  1851. this.ServeJSON()
  1852. return
  1853. }
  1854. var model supplierapplytime.OilSupplierApplyTime
  1855. svc := suppliercert.GetOilSupplierCertSession(session)
  1856. var jsonBlob = this.Ctx.Input.RequestBody
  1857. json.Unmarshal(jsonBlob, &model)
  1858. model.CreateOn = time.Now()
  1859. model.CreateBy = this.User.Realname
  1860. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1861. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  1862. _, err := svc.InsertEntityBytbl(SupplierApplyTimeName, &model)
  1863. if err != nil {
  1864. session.Rollback()
  1865. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1866. errinfo.Code = -1
  1867. this.Data["json"] = &errinfo
  1868. this.ServeJSON()
  1869. return
  1870. }
  1871. var modelcert suppliercert.OilSupplierCert
  1872. modelcert.ApplyTime = model.AfterDate
  1873. if model.AfterDate.Unix() < time.Now().Unix() {
  1874. modelcert.InFlag = "2"
  1875. } else {
  1876. modelcert.InFlag = "1"
  1877. }
  1878. var cols = []string{
  1879. "ApplyTime",
  1880. "InFlag",
  1881. }
  1882. err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &modelcert, cols)
  1883. if err != nil {
  1884. session.Rollback()
  1885. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1886. errinfo.Code = -1
  1887. this.Data["json"] = &errinfo
  1888. this.ServeJSON()
  1889. return
  1890. }
  1891. err = session.Commit()
  1892. if err == nil {
  1893. errinfo.Message = "修改成功!"
  1894. errinfo.Code = 0
  1895. this.Data["json"] = &errinfo
  1896. this.ServeJSON()
  1897. } else {
  1898. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1899. errinfo.Code = -1
  1900. this.Data["json"] = &errinfo
  1901. this.ServeJSON()
  1902. }
  1903. }
  1904. // @Title 获取列表
  1905. // @Description get user by token
  1906. // @Success 200 {object} []suppliercert.OilSupplierCert
  1907. // @router /getapplytimelist [get]
  1908. func (this *OilSupplierCertController) GetApplyTimeList() {
  1909. SupplierCertId := this.GetString("SupplierCertId")
  1910. var model []supplierapplytime.OilSupplierApplyTime
  1911. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1912. where := "SupplierCertId = " + SupplierCertId
  1913. svc.GetEntities(&model, where)
  1914. var errinfo ErrorDataInfo
  1915. errinfo.Message = "修改成功!"
  1916. errinfo.Code = 0
  1917. errinfo.Item = model
  1918. this.Data["json"] = &model
  1919. this.ServeJSON()
  1920. }