suppliercert.go 68 KB

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