supplier.go 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  4. "dashoo.cn/backend/api/business/register"
  5. "encoding/json"
  6. "fmt"
  7. "strconv"
  8. "strings"
  9. "time"
  10. "dashoo.cn/backend/api/business/auditsetting"
  11. "dashoo.cn/backend/api/business/organize"
  12. "dashoo.cn/business2/permission"
  13. "dashoo.cn/backend/api/business/workflow"
  14. "dashoo.cn/business2/areajson"
  15. "dashoo.cn/business2/items"
  16. "dashoo.cn/backend/api/business/baseUser"
  17. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  18. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  19. . "dashoo.cn/backend/api/controllers"
  20. "dashoo.cn/business2/userRole"
  21. "dashoo.cn/utils"
  22. "github.com/go-xorm/xorm"
  23. )
  24. type OilSupplierController struct {
  25. BaseController
  26. }
  27. // @Title 获取列表
  28. // @Description get user by token
  29. // @Success 200 {object} []supplier.OilSupplier
  30. // @router /list [get]
  31. func (this *OilSupplierController) GetEntityList() {
  32. //获取分页信息
  33. page := this.GetPageInfoForm()
  34. where := " 1=1 "
  35. orderby := "Id"
  36. asc := false
  37. Order := this.GetString("Order")
  38. Prop := this.GetString("Prop")
  39. if Order != "" && Prop != "" {
  40. orderby = Prop
  41. if Order == "asc" {
  42. asc = true
  43. }
  44. }
  45. Id := this.GetString("Id")
  46. SupplierName := this.GetString("SupplierName")
  47. OilCertificateNo := this.GetString("OilCertificateNo")
  48. Grade := this.GetString("Grade")
  49. MgrUnit := this.GetString("MgrUnit")
  50. OperType := this.GetString("OperType")
  51. Country := this.GetString("Country")
  52. MaunAgent := this.GetString("MaunAgent")
  53. ConstructTeam := this.GetString("ConstructTeam")
  54. CommercialNo := this.GetString("CommercialNo")
  55. OrganCode := this.GetString("OrganCode")
  56. CountryTaxNo := this.GetString("CountryTaxNo")
  57. LocalTaxNo := this.GetString("LocalTaxNo")
  58. Address := this.GetString("Address")
  59. Province := this.GetString("Province")
  60. City := this.GetString("City")
  61. Street := this.GetString("Street")
  62. HouseNo := this.GetString("HouseNo")
  63. ZipCode := this.GetString("ZipCode")
  64. QualitySystemCert := this.GetString("QualitySystemCert")
  65. ProductQualityCert := this.GetString("ProductQualityCert")
  66. MaunLicense := this.GetString("MaunLicense")
  67. QualifCert := this.GetString("QualifCert")
  68. QualifCertLevel := this.GetString("QualifCertLevel")
  69. SafetyLicense := this.GetString("SafetyLicense")
  70. TechServiceLic := this.GetString("TechServiceLic")
  71. TJInNotify := this.GetString("TJInNotify")
  72. SpecIndustryCert := this.GetString("SpecIndustryCert")
  73. LegalPerson := this.GetString("LegalPerson")
  74. CategoryCode := this.GetString("CategoryCode")
  75. CategoryName := this.GetString("CategoryName")
  76. RegCapital := this.GetString("RegCapital")
  77. Currency := this.GetString("Currency")
  78. ContactName := this.GetString("ContactName")
  79. CompanyType := this.GetString("CompanyType")
  80. SetupTime := this.GetString("SetupTime")
  81. DepositBank := this.GetString("DepositBank")
  82. BankAccount := this.GetString("BankAccount")
  83. EMail := this.GetString("EMail")
  84. BankCreditRating := this.GetString("BankCreditRating")
  85. Mobile := this.GetString("Mobile")
  86. Telphone := this.GetString("Telphone")
  87. Fax := this.GetString("Fax")
  88. CompanyTel := this.GetString("CompanyTel")
  89. QQ := this.GetString("QQ")
  90. CompanyUrl := this.GetString("CompanyUrl")
  91. SpecSupplier := this.GetString("SpecSupplier")
  92. SpecTypeCode := this.GetString("SpecTypeCode")
  93. SpecTypeName := this.GetString("SpecTypeName")
  94. Remark := this.GetString("Remark")
  95. IsDelete := this.GetString("IsDelete")
  96. CreateOn := this.GetString("CreateOn")
  97. CreateUserId := this.GetString("CreateUserId")
  98. CreateBy := this.GetString("CreateBy")
  99. ModifiedOn := this.GetString("ModifiedOn")
  100. ModifiedUserId := this.GetString("ModifiedUserId")
  101. ModifiedBy := this.GetString("ModifiedBy")
  102. if Id != "" {
  103. where = where + " and Id like '%" + Id + "%'"
  104. }
  105. if SupplierName != "" {
  106. where = where + " and SupplierName like '%" + SupplierName + "%'"
  107. }
  108. if OilCertificateNo != "" {
  109. where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
  110. }
  111. if Grade != "" {
  112. where = where + " and Grade like '%" + Grade + "%'"
  113. }
  114. if MgrUnit != "" {
  115. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  116. }
  117. if OperType != "" {
  118. where = where + " and OperType like '%" + OperType + "%'"
  119. }
  120. if Country != "" {
  121. where = where + " and Country like '%" + Country + "%'"
  122. }
  123. if MaunAgent != "" {
  124. where = where + " and MaunAgent like '%" + MaunAgent + "%'"
  125. }
  126. if ConstructTeam != "" {
  127. where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
  128. }
  129. if CommercialNo != "" {
  130. where = where + " and CommercialNo like '%" + CommercialNo + "%'"
  131. }
  132. if OrganCode != "" {
  133. where = where + " and OrganCode like '%" + OrganCode + "%'"
  134. }
  135. if CountryTaxNo != "" {
  136. where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
  137. }
  138. if LocalTaxNo != "" {
  139. where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
  140. }
  141. if Address != "" {
  142. where = where + " and Address like '%" + Address + "%'"
  143. }
  144. if Province != "" {
  145. where = where + " and Province like '%" + Province + "%'"
  146. }
  147. if City != "" {
  148. where = where + " and City like '%" + City + "%'"
  149. }
  150. if Street != "" {
  151. where = where + " and Street like '%" + Street + "%'"
  152. }
  153. if HouseNo != "" {
  154. where = where + " and HouseNo like '%" + HouseNo + "%'"
  155. }
  156. if ZipCode != "" {
  157. where = where + " and ZipCode like '%" + ZipCode + "%'"
  158. }
  159. if QualitySystemCert != "" {
  160. where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
  161. }
  162. if ProductQualityCert != "" {
  163. where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
  164. }
  165. if MaunLicense != "" {
  166. where = where + " and MaunLicense like '%" + MaunLicense + "%'"
  167. }
  168. if QualifCert != "" {
  169. where = where + " and QualifCert like '%" + QualifCert + "%'"
  170. }
  171. if QualifCertLevel != "" {
  172. where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
  173. }
  174. if SafetyLicense != "" {
  175. where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
  176. }
  177. if TechServiceLic != "" {
  178. where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
  179. }
  180. if TJInNotify != "" {
  181. where = where + " and TJInNotify like '%" + TJInNotify + "%'"
  182. }
  183. if SpecIndustryCert != "" {
  184. where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  185. }
  186. if LegalPerson != "" {
  187. where = where + " and LegalPerson like '%" + LegalPerson + "%'"
  188. }
  189. if CategoryCode != "" {
  190. where = where + " and CategoryCode like '%" + CategoryCode + "%'"
  191. }
  192. if CategoryName != "" {
  193. where = where + " and CategoryName like '%" + CategoryName + "%'"
  194. }
  195. if RegCapital != "" {
  196. where = where + " and RegCapital like '%" + RegCapital + "%'"
  197. }
  198. if Currency != "" {
  199. where = where + " and Currency like '%" + Currency + "%'"
  200. }
  201. if ContactName != "" {
  202. where = where + " and ContactName like '%" + ContactName + "%'"
  203. }
  204. if CompanyType != "" {
  205. where = where + " and CompanyType like '%" + CompanyType + "%'"
  206. }
  207. if SetupTime != "" {
  208. where = where + " and SetupTime like '%" + SetupTime + "%'"
  209. }
  210. if DepositBank != "" {
  211. where = where + " and DepositBank like '%" + DepositBank + "%'"
  212. }
  213. if BankAccount != "" {
  214. where = where + " and BankAccount like '%" + BankAccount + "%'"
  215. }
  216. if EMail != "" {
  217. where = where + " and EMail like '%" + EMail + "%'"
  218. }
  219. if BankCreditRating != "" {
  220. where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
  221. }
  222. if Mobile != "" {
  223. where = where + " and Mobile like '%" + Mobile + "%'"
  224. }
  225. if Telphone != "" {
  226. where = where + " and Telphone like '%" + Telphone + "%'"
  227. }
  228. if Fax != "" {
  229. where = where + " and Fax like '%" + Fax + "%'"
  230. }
  231. if CompanyTel != "" {
  232. where = where + " and CompanyTel like '%" + CompanyTel + "%'"
  233. }
  234. if QQ != "" {
  235. where = where + " and QQ like '%" + QQ + "%'"
  236. }
  237. if CompanyUrl != "" {
  238. where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
  239. }
  240. if SpecSupplier != "" {
  241. where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
  242. }
  243. if SpecTypeCode != "" {
  244. where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
  245. }
  246. if SpecTypeName != "" {
  247. where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
  248. }
  249. if Remark != "" {
  250. where = where + " and Remark like '%" + Remark + "%'"
  251. }
  252. if IsDelete != "" {
  253. where = where + " and IsDelete like '%" + IsDelete + "%'"
  254. }
  255. if CreateUserId != "" {
  256. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  257. }
  258. if CreateBy != "" {
  259. where = where + " and CreateBy like '%" + CreateBy + "%'"
  260. }
  261. if ModifiedOn != "" {
  262. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  263. }
  264. if ModifiedUserId != "" {
  265. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  266. }
  267. if ModifiedBy != "" {
  268. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  269. }
  270. if CreateOn != "" {
  271. dates := strings.Split(CreateOn, ",")
  272. if len(dates) == 2 {
  273. minDate := dates[0]
  274. maxDate := dates[1]
  275. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  276. }
  277. }
  278. //企业用户必须加创建人条件
  279. if this.User.IsCompanyUser == 1 {
  280. where = where + " and CreateUserId = '" + this.User.Id + "'"
  281. } else {
  282. //超级管理员和有查看所有数据权限的用户不加条件
  283. svcPerm := permission.GetPermissionService(utils.DBE)
  284. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  285. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  286. where = where + " and CreateUserId = '" + this.User.Id + "'"
  287. }
  288. }
  289. svc := supplier.GetOilSupplierService(utils.DBE)
  290. var list []supplier.OilSupplier
  291. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  292. var datainfo DataInfo
  293. datainfo.Items = list
  294. datainfo.CurrentItemCount = total
  295. datainfo.PageIndex = page.CurrentPage
  296. datainfo.ItemsPerPage = page.Size
  297. this.Data["json"] = &datainfo
  298. this.ServeJSON()
  299. }
  300. // @Title 获取列表
  301. // @Description get user by token
  302. // @Success 200 {object} []supplier.OilSupplier
  303. // @router /certlist [get]
  304. func (this *OilSupplierController) GetJoinCertEntityList() {
  305. //获取分页信息
  306. page := this.GetPageInfoForm()
  307. where := " 1=1 "
  308. orderby := "Id"
  309. asc := false
  310. Order := this.GetString("Order")
  311. Prop := this.GetString("Prop")
  312. if Order != "" && Prop != "" {
  313. orderby = Prop
  314. if Order == "asc" {
  315. asc = true
  316. }
  317. }
  318. SupplierName := this.GetString("SupplierName")
  319. SupplierTypeName := this.GetString("SupplierTypeName")
  320. CreateOn := this.GetString("CreateOn")
  321. SupplierTypeCode := this.GetString("SupplierTypeCode")
  322. OperType := this.GetString("OperType")
  323. SpecTypeCode := this.GetString("SpecTypeCode")
  324. Country := this.GetString("Country")
  325. InStyle := this.GetString("InStyle")
  326. MgrUnit := this.GetString("MgrUnit")
  327. PACNumber := this.GetString("PACNumber")
  328. CommercialNo := this.GetString("CommercialNo")
  329. Province := this.GetString("Province")
  330. City := this.GetString("City")
  331. Street := this.GetString("Street")
  332. Address := this.GetString("Address")
  333. LinkProvince := this.GetString("LinkProvince")
  334. LinkCity := this.GetString("LinkCity")
  335. LinkStreet := this.GetString("LinkStreet")
  336. LinkAddress := this.GetString("LinkAddress")
  337. LegalPerson := this.GetString("LegalPerson")
  338. ContactName := this.GetString("ContactName")
  339. CompanyType := this.GetString("CompanyType")
  340. SetupTime := this.GetString("SetupTime")
  341. RegCapital1 := this.GetString("RegCapital1")
  342. RegCapital2 := this.GetString("RegCapital2")
  343. BusinessScope := this.GetString("BusinessScope")
  344. if SupplierName != "" {
  345. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  346. }
  347. if SupplierTypeName != "" {
  348. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  349. }
  350. if CreateOn != "" {
  351. dates := strings.Split(CreateOn, ",")
  352. if len(dates) == 2 {
  353. minDate := dates[0]
  354. maxDate := dates[1]
  355. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  356. }
  357. }
  358. if SupplierTypeCode != "" {
  359. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  360. }
  361. if OperType != "" {
  362. where = where + " and a.OperType like '%" + OperType + "%'"
  363. }
  364. if SpecTypeCode != "" {
  365. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  366. }
  367. if Country != "" {
  368. where = where + " and a.Country like '%" + Country + "%'"
  369. }
  370. if InStyle != "" {
  371. where = where + " and b.InStyle ='" + InStyle + "'"
  372. }
  373. if MgrUnit != "" {
  374. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  375. }
  376. if PACNumber != "" {
  377. where = where + " and a.PACNumber ='" + PACNumber + "'"
  378. }
  379. if CommercialNo != "" {
  380. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  381. }
  382. if Province != "" {
  383. where = where + " and a.Province ='" + Province + "'"
  384. }
  385. if City != "" {
  386. where = where + " and a.City ='" + City + "'"
  387. }
  388. if Street != "" {
  389. where = where + " and a.Street ='" + Street + "'"
  390. }
  391. if Address != "" {
  392. where = where + " and a.Address ='" + Address + "'"
  393. }
  394. if LinkProvince != "" {
  395. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  396. }
  397. if LinkCity != "" {
  398. where = where + " and a.LinkCity ='" + LinkCity + "'"
  399. }
  400. if LinkStreet != "" {
  401. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  402. }
  403. if LinkAddress != "" {
  404. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  405. }
  406. if LegalPerson != "" {
  407. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  408. }
  409. if ContactName != "" {
  410. where = where + " and a.ContactName ='" + ContactName + "'"
  411. }
  412. if CompanyType != "" {
  413. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  414. }
  415. if SetupTime != "" {
  416. where = where + " and a.SetupTime ='" + SetupTime + "'"
  417. }
  418. //注册资金范围
  419. if RegCapital1 != "" {
  420. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  421. }
  422. if RegCapital2 != "" {
  423. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  424. }
  425. if BusinessScope != "" {
  426. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  427. }
  428. //企业用户只看自己的数据记录
  429. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  430. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  431. if extOrganizeId == this.User.DepartmentId {
  432. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  433. }*/
  434. svc := supplier.GetOilSupplierService(utils.DBE)
  435. var registerUser register.OilCorporateInfo
  436. sql := " UserName='" + this.User.Username + "'"
  437. svc.GetEntity(&registerUser,sql)
  438. //企业用户必须加创建人条件
  439. if this.User.IsCompanyUser == 1 {
  440. where = where + " and (a.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+registerUser.CommercialNo+"')"
  441. } else {
  442. //超级管理员和有查看所有数据权限的用户不加条件
  443. svcPerm := permission.GetPermissionService(utils.DBE)
  444. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  445. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  446. where = where + " and b.CreateUserId = '" + this.User.Id + "'"
  447. }
  448. }
  449. var list []supplier.OilSupplierView
  450. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  451. var datainfo DataInfo
  452. datainfo.Items = list
  453. datainfo.CurrentItemCount = total
  454. datainfo.PageIndex = page.CurrentPage
  455. datainfo.ItemsPerPage = page.Size
  456. this.Data["json"] = &datainfo
  457. this.ServeJSON()
  458. }
  459. // @Title 获取集中评审列表
  460. // @Description get user by token
  461. // @Success 200 {object} []supplier.OilSupplier
  462. // @router /jzps_certlist [get]
  463. func (this *OilSupplierController) GetJZPSJoinCertEntityList() {
  464. //获取分页信息
  465. page := this.GetPageInfoForm()
  466. where := " 1=1 "
  467. orderby := "Id"
  468. asc := false
  469. Order := this.GetString("Order")
  470. Prop := this.GetString("Prop")
  471. if Order != "" && Prop != "" {
  472. orderby = Prop
  473. if Order == "asc" {
  474. asc = true
  475. }
  476. }
  477. SupplierName := this.GetString("SupplierName")
  478. SupplierTypeName := this.GetString("SupplierTypeName")
  479. CreateOn := this.GetString("CreateOn")
  480. SupplierTypeCode := this.GetString("SupplierTypeCode")
  481. OperType := this.GetString("OperType")
  482. SpecTypeCode := this.GetString("SpecTypeCode")
  483. Country := this.GetString("Country")
  484. InStyle := this.GetString("InStyle")
  485. MgrUnit := this.GetString("MgrUnit")
  486. PACNumber := this.GetString("PACNumber")
  487. CommercialNo := this.GetString("CommercialNo")
  488. Province := this.GetString("Province")
  489. City := this.GetString("City")
  490. Street := this.GetString("Street")
  491. Address := this.GetString("Address")
  492. LinkProvince := this.GetString("LinkProvince")
  493. LinkCity := this.GetString("LinkCity")
  494. LinkStreet := this.GetString("LinkStreet")
  495. LinkAddress := this.GetString("LinkAddress")
  496. LegalPerson := this.GetString("LegalPerson")
  497. ContactName := this.GetString("ContactName")
  498. CompanyType := this.GetString("CompanyType")
  499. SetupTime := this.GetString("SetupTime")
  500. RegCapital1 := this.GetString("RegCapital1")
  501. RegCapital2 := this.GetString("RegCapital2")
  502. BusinessScope := this.GetString("BusinessScope")
  503. if SupplierName != "" {
  504. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  505. }
  506. if SupplierTypeName != "" {
  507. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  508. }
  509. if CreateOn != "" {
  510. dates := strings.Split(CreateOn, ",")
  511. if len(dates) == 2 {
  512. minDate := dates[0]
  513. maxDate := dates[1]
  514. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  515. }
  516. }
  517. if SupplierTypeCode != "" {
  518. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  519. }
  520. if OperType != "" {
  521. where = where + " and a.OperType like '%" + OperType + "%'"
  522. }
  523. if SpecTypeCode != "" {
  524. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  525. }
  526. if Country != "" {
  527. where = where + " and a.Country like '%" + Country + "%'"
  528. }
  529. if InStyle != "" {
  530. where = where + " and b.InStyle ='" + InStyle + "'"
  531. }
  532. if MgrUnit != "" {
  533. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  534. }
  535. if PACNumber != "" {
  536. where = where + " and a.PACNumber ='" + PACNumber + "'"
  537. }
  538. if CommercialNo != "" {
  539. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  540. }
  541. if Province != "" {
  542. where = where + " and a.Province ='" + Province + "'"
  543. }
  544. if City != "" {
  545. where = where + " and a.City ='" + City + "'"
  546. }
  547. if Street != "" {
  548. where = where + " and a.Street ='" + Street + "'"
  549. }
  550. if Address != "" {
  551. where = where + " and a.Address ='" + Address + "'"
  552. }
  553. if LinkProvince != "" {
  554. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  555. }
  556. if LinkCity != "" {
  557. where = where + " and a.LinkCity ='" + LinkCity + "'"
  558. }
  559. if LinkStreet != "" {
  560. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  561. }
  562. if LinkAddress != "" {
  563. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  564. }
  565. if LegalPerson != "" {
  566. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  567. }
  568. if ContactName != "" {
  569. where = where + " and a.ContactName ='" + ContactName + "'"
  570. }
  571. if CompanyType != "" {
  572. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  573. }
  574. if SetupTime != "" {
  575. where = where + " and a.SetupTime ='" + SetupTime + "'"
  576. }
  577. //注册资金范围
  578. if RegCapital1 != "" {
  579. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  580. }
  581. if RegCapital2 != "" {
  582. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  583. }
  584. if BusinessScope != "" {
  585. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  586. }
  587. status := this.GetString("Status")
  588. if status != "" {
  589. where = where + " and b.Status='" + status + "'"
  590. }
  591. //企业用户必须加创建人条件
  592. if this.User.IsCompanyUser == 1 {
  593. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  594. } else {
  595. //超级管理员和有查看所有数据权限的用户不加条件
  596. svcPerm := permission.GetPermissionService(utils.DBE)
  597. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  598. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  599. //根据工作流查找
  600. //集中评审相关人可看数据
  601. actisvc := workflow.GetActivitiService(utils.DBE)
  602. //找出待办任务===准入
  603. var certIdList string
  604. ids := actisvc.GetAllMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  605. if len(strings.Trim(ids, ",")) > 0 {
  606. certIdList += strings.Trim(ids, ",")+ ","
  607. }
  608. ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id)
  609. if len(strings.Trim(ids, ",")) > 0 {
  610. certIdList += strings.Trim(ids, ",")+ ","
  611. }
  612. ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id)
  613. if len(strings.Trim(ids, ",")) > 0 {
  614. certIdList += strings.Trim(ids, ",")+ ","
  615. }
  616. ids = actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  617. if len(strings.Trim(ids, ",")) > 0 {
  618. certIdList += strings.Trim(ids, ",")+ ","
  619. }
  620. ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  621. if len(strings.Trim(ids, ",")) > 0 {
  622. certIdList += strings.Trim(ids, ",")+ ","
  623. }
  624. ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  625. if len(strings.Trim(ids, ",")) > 0 {
  626. certIdList += strings.Trim(ids, ",")+ ","
  627. }
  628. certIdList = strings.Trim(certIdList, ",")
  629. certIdarr := strings.Split(certIdList, ",")
  630. for i, item := range certIdarr {
  631. idx := strings.Index(item, "-")
  632. if idx >= 0 {
  633. certIdarr[i] = strings.Split(item, "-")[0]
  634. }
  635. }
  636. certIdList = strings.Join(certIdarr, ",")
  637. if certIdList != "" {
  638. where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
  639. } else {
  640. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  641. }
  642. } else {
  643. //where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  644. }
  645. }
  646. svc := supplier.GetOilSupplierService(utils.DBE)
  647. var list []supplier.OilSupplierView
  648. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  649. var datainfo DataInfo
  650. datainfo.Items = list
  651. datainfo.CurrentItemCount = total
  652. datainfo.PageIndex = page.CurrentPage
  653. datainfo.ItemsPerPage = page.Size
  654. this.Data["json"] = &datainfo
  655. this.ServeJSON()
  656. }
  657. // @Title 企业入库列表
  658. // @Description get user by token
  659. // @Success 200 {object} []supplier.OilSupplier
  660. // @router /storelist [get]
  661. func (this *OilSupplierController) GetJoinStoreEntityList() {
  662. //获取分页信息
  663. page := this.GetPageInfoForm()
  664. where := " 1=1 "
  665. orderby := "Id"
  666. asc := false
  667. Order := this.GetString("Order")
  668. Prop := this.GetString("Prop")
  669. if Order != "" && Prop != "" {
  670. orderby = Prop
  671. if Order == "asc" {
  672. asc = true
  673. }
  674. }
  675. SupplierName := this.GetString("SupplierName")
  676. SupplierTypeName := this.GetString("SupplierTypeName")
  677. CreateOn := this.GetString("CreateOn")
  678. SupplierTypeCode := this.GetString("SupplierTypeCode")
  679. OperType := this.GetString("OperType")
  680. SpecTypeCode := this.GetString("SpecTypeCode")
  681. Country := this.GetString("Country")
  682. InStyle := this.GetString("InStyle")
  683. MgrUnit := this.GetString("MgrUnit")
  684. PACNumber := this.GetString("PACNumber")
  685. CommercialNo := this.GetString("CommercialNo")
  686. Province := this.GetString("Province")
  687. City := this.GetString("City")
  688. Street := this.GetString("Street")
  689. Address := this.GetString("Address")
  690. LinkProvince := this.GetString("LinkProvince")
  691. LinkCity := this.GetString("LinkCity")
  692. LinkStreet := this.GetString("LinkStreet")
  693. LinkAddress := this.GetString("LinkAddress")
  694. LegalPerson := this.GetString("LegalPerson")
  695. ContactName := this.GetString("ContactName")
  696. CompanyType := this.GetString("CompanyType")
  697. SetupTime := this.GetString("SetupTime")
  698. RegCapital1 := this.GetString("RegCapital1")
  699. RegCapital2 := this.GetString("RegCapital2")
  700. BusinessScope := this.GetString("BusinessScope")
  701. if SupplierName != "" {
  702. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  703. }
  704. if SupplierTypeName != "" {
  705. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  706. }
  707. if CreateOn != "" {
  708. dates := strings.Split(CreateOn, ",")
  709. if len(dates) == 2 {
  710. minDate := dates[0]
  711. maxDate := dates[1]
  712. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  713. }
  714. }
  715. if SupplierTypeCode != "" {
  716. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  717. }
  718. if OperType != "" {
  719. where = where + " and a.OperType like '%" + OperType + "%'"
  720. }
  721. if SpecTypeCode != "" {
  722. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  723. }
  724. if Country != "" {
  725. where = where + " and a.Country like '%" + Country + "%'"
  726. }
  727. if InStyle != "" {
  728. where = where + " and b.InStyle ='" + InStyle + "'"
  729. }
  730. if MgrUnit != "" {
  731. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  732. }
  733. if PACNumber != "" {
  734. where = where + " and a.PACNumber ='" + PACNumber + "'"
  735. }
  736. if CommercialNo != "" {
  737. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  738. }
  739. if Province != "" {
  740. where = where + " and a.Province ='" + Province + "'"
  741. }
  742. if City != "" {
  743. where = where + " and a.City ='" + City + "'"
  744. }
  745. if Street != "" {
  746. where = where + " and a.Street ='" + Street + "'"
  747. }
  748. if Address != "" {
  749. where = where + " and a.Address ='" + Address + "'"
  750. }
  751. if LinkProvince != "" {
  752. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  753. }
  754. if LinkCity != "" {
  755. where = where + " and a.LinkCity ='" + LinkCity + "'"
  756. }
  757. if LinkStreet != "" {
  758. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  759. }
  760. if LinkAddress != "" {
  761. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  762. }
  763. if LegalPerson != "" {
  764. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  765. }
  766. if ContactName != "" {
  767. where = where + " and a.ContactName ='" + ContactName + "'"
  768. }
  769. if CompanyType != "" {
  770. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  771. }
  772. if SetupTime != "" {
  773. where = where + " and a.SetupTime ='" + SetupTime + "'"
  774. }
  775. //注册资金范围
  776. if RegCapital1 != "" {
  777. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  778. }
  779. if RegCapital2 != "" {
  780. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  781. }
  782. if BusinessScope != "" {
  783. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  784. }
  785. status := this.GetString("Status")
  786. if status != "" {
  787. where = where + " and b.Status='" + status + "'"
  788. }
  789. //企业用户只看自己的数据记录
  790. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  791. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  792. if extOrganizeId == this.User.DepartmentId {
  793. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  794. }*/
  795. //企业用户必须加创建人条件
  796. if this.User.IsCompanyUser == 1 {
  797. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  798. }
  799. svc := supplier.GetOilSupplierService(utils.DBE)
  800. var list []supplier.OilSupplierView
  801. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  802. var datainfo DataInfo
  803. datainfo.Items = list
  804. datainfo.CurrentItemCount = total
  805. datainfo.PageIndex = page.CurrentPage
  806. datainfo.ItemsPerPage = page.Size
  807. this.Data["json"] = &datainfo
  808. this.ServeJSON()
  809. }
  810. // @Title 获取列表
  811. // @Description get user by token
  812. // @Success 200 {object} []supplier.OilSupplierView
  813. // @router /mytasks [get]
  814. func (this *OilSupplierController) GetMyTaskEntityList() {
  815. //获取分页信息
  816. page := this.GetPageInfoForm()
  817. where := " 1=1 "
  818. orderby := "Id"
  819. asc := false
  820. Order := this.GetString("Order")
  821. //Statustype := this.GetString("Statustype")
  822. //if Statustype != "" {
  823. // where = " 1=1 and b.Status =" + Statustype
  824. //}
  825. where = where + " and b.Status>0"
  826. Prop := this.GetString("Prop")
  827. if Order != "" && Prop != "" {
  828. orderby = Prop
  829. if Order == "asc" {
  830. asc = true
  831. }
  832. }
  833. Id := this.GetString("Id")
  834. SupplierName := this.GetString("SupplierName")
  835. OilCertificateNo := this.GetString("OilCertificateNo")
  836. Grade := this.GetString("Grade")
  837. MgrUnit := this.GetString("MgrUnit")
  838. OperType := this.GetString("OperType")
  839. Country := this.GetString("Country")
  840. MaunAgent := this.GetString("MaunAgent")
  841. ConstructTeam := this.GetString("ConstructTeam")
  842. CommercialNo := this.GetString("CommercialNo")
  843. OrganCode := this.GetString("OrganCode")
  844. CountryTaxNo := this.GetString("CountryTaxNo")
  845. LocalTaxNo := this.GetString("LocalTaxNo")
  846. Address := this.GetString("Address")
  847. Province := this.GetString("Province")
  848. City := this.GetString("City")
  849. Street := this.GetString("Street")
  850. HouseNo := this.GetString("HouseNo")
  851. ZipCode := this.GetString("ZipCode")
  852. QualitySystemCert := this.GetString("QualitySystemCert")
  853. ProductQualityCert := this.GetString("ProductQualityCert")
  854. MaunLicense := this.GetString("MaunLicense")
  855. QualifCert := this.GetString("QualifCert")
  856. QualifCertLevel := this.GetString("QualifCertLevel")
  857. SafetyLicense := this.GetString("SafetyLicense")
  858. TechServiceLic := this.GetString("TechServiceLic")
  859. TJInNotify := this.GetString("TJInNotify")
  860. SpecIndustryCert := this.GetString("SpecIndustryCert")
  861. LegalPerson := this.GetString("LegalPerson")
  862. CategoryCode := this.GetString("CategoryCode")
  863. CategoryName := this.GetString("CategoryName")
  864. RegCapital := this.GetString("RegCapital")
  865. Currency := this.GetString("Currency")
  866. ContactName := this.GetString("ContactName")
  867. CompanyType := this.GetString("CompanyType")
  868. SetupTime := this.GetString("SetupTime")
  869. DepositBank := this.GetString("DepositBank")
  870. BankAccount := this.GetString("BankAccount")
  871. EMail := this.GetString("EMail")
  872. BankCreditRating := this.GetString("BankCreditRating")
  873. Mobile := this.GetString("Mobile")
  874. Telphone := this.GetString("Telphone")
  875. Fax := this.GetString("Fax")
  876. CompanyTel := this.GetString("CompanyTel")
  877. QQ := this.GetString("QQ")
  878. CompanyUrl := this.GetString("CompanyUrl")
  879. SpecSupplier := this.GetString("SpecSupplier")
  880. SpecTypeCode := this.GetString("SpecTypeCode")
  881. SpecTypeName := this.GetString("SpecTypeName")
  882. Remark := this.GetString("Remark")
  883. CreateOn := this.GetString("CreateOn")
  884. SupplierTypeCode := this.GetString("SupplierTypeCode")
  885. if Id != "" {
  886. where = where + " and a.Id like '%" + Id + "%'"
  887. }
  888. if SupplierName != "" {
  889. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  890. }
  891. if OilCertificateNo != "" {
  892. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  893. }
  894. if Grade != "" {
  895. where = where + " and a.Grade like '%" + Grade + "%'"
  896. }
  897. if MgrUnit != "" {
  898. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  899. }
  900. if OperType != "" {
  901. where = where + " and a.OperType like '%" + OperType + "%'"
  902. }
  903. if Country != "" {
  904. where = where + " and a.Country like '%" + Country + "%'"
  905. }
  906. if MaunAgent != "" {
  907. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  908. }
  909. if ConstructTeam != "" {
  910. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  911. }
  912. if CommercialNo != "" {
  913. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  914. }
  915. if OrganCode != "" {
  916. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  917. }
  918. if CountryTaxNo != "" {
  919. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  920. }
  921. if LocalTaxNo != "" {
  922. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  923. }
  924. if Address != "" {
  925. where = where + " and a.Address like '%" + Address + "%'"
  926. }
  927. if Province != "" {
  928. where = where + " and a.Province like '%" + Province + "%'"
  929. }
  930. if City != "" {
  931. where = where + " and a.City like '%" + City + "%'"
  932. }
  933. if Street != "" {
  934. where = where + " and a.Street like '%" + Street + "%'"
  935. }
  936. if HouseNo != "" {
  937. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  938. }
  939. if ZipCode != "" {
  940. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  941. }
  942. if QualitySystemCert != "" {
  943. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  944. }
  945. if ProductQualityCert != "" {
  946. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  947. }
  948. if MaunLicense != "" {
  949. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  950. }
  951. if QualifCert != "" {
  952. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  953. }
  954. if QualifCertLevel != "" {
  955. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  956. }
  957. if SafetyLicense != "" {
  958. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  959. }
  960. if TechServiceLic != "" {
  961. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  962. }
  963. if TJInNotify != "" {
  964. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  965. }
  966. if SpecIndustryCert != "" {
  967. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  968. }
  969. if LegalPerson != "" {
  970. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  971. }
  972. if CategoryCode != "" {
  973. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  974. }
  975. if CategoryName != "" {
  976. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  977. }
  978. if RegCapital != "" {
  979. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  980. }
  981. if Currency != "" {
  982. where = where + " and a.Currency like '%" + Currency + "%'"
  983. }
  984. if ContactName != "" {
  985. where = where + " and a.ContactName like '%" + ContactName + "%'"
  986. }
  987. if CompanyType != "" {
  988. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  989. }
  990. if SetupTime != "" {
  991. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  992. }
  993. if DepositBank != "" {
  994. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  995. }
  996. if BankAccount != "" {
  997. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  998. }
  999. if EMail != "" {
  1000. where = where + " and a.EMail like '%" + EMail + "%'"
  1001. }
  1002. if BankCreditRating != "" {
  1003. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  1004. }
  1005. if Mobile != "" {
  1006. where = where + " and a.Mobile like '%" + Mobile + "%'"
  1007. }
  1008. if Telphone != "" {
  1009. where = where + " and a.Telphone like '%" + Telphone + "%'"
  1010. }
  1011. if Fax != "" {
  1012. where = where + " and a.Fax like '%" + Fax + "%'"
  1013. }
  1014. if CompanyTel != "" {
  1015. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  1016. }
  1017. if QQ != "" {
  1018. where = where + " and a.QQ like '%" + QQ + "%'"
  1019. }
  1020. if CompanyUrl != "" {
  1021. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  1022. }
  1023. if SpecSupplier != "" {
  1024. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  1025. }
  1026. if SpecTypeCode != "" {
  1027. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  1028. }
  1029. if SpecTypeName != "" {
  1030. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  1031. }
  1032. if Remark != "" {
  1033. where = where + " and a.Remark like '%" + Remark + "%'"
  1034. }
  1035. if CreateOn != "" {
  1036. dates := strings.Split(CreateOn, ",")
  1037. if len(dates) == 2 {
  1038. minDate := dates[0]
  1039. maxDate := dates[1]
  1040. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1041. }
  1042. }
  1043. if SupplierTypeCode != "" {
  1044. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1045. }
  1046. //找出待办任务
  1047. actisvc := workflow.GetActivitiService(utils.DBE)
  1048. var certIdList string
  1049. if actisvc.GetMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id) != "" {
  1050. certIdList = actisvc.GetMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  1051. certIdList = certIdList + ","
  1052. }
  1053. if actisvc.GetMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id) != "" {
  1054. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id))
  1055. certIdList = certIdList + ","
  1056. }
  1057. if actisvc.GetMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id) != "" {
  1058. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id))
  1059. certIdList = certIdList + ","
  1060. }
  1061. if actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1062. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1063. certIdList = certIdList + ","
  1064. }
  1065. if actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1066. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1067. certIdList = certIdList + ","
  1068. }
  1069. if actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1070. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1071. }
  1072. certIdList = strings.Trim(certIdList, ",")
  1073. certIdarr := strings.Split(certIdList, ",")
  1074. for i, item := range certIdarr {
  1075. idx := strings.Index(item, "-")
  1076. if idx >= 0 {
  1077. certIdarr[i] = strings.Split(item, "-")[0]
  1078. }
  1079. }
  1080. certIdList = strings.Join(certIdarr, ",")
  1081. var list []supplier.OilSupplierView
  1082. svc := supplier.GetOilSupplierService(utils.DBE)
  1083. var total int64 = 0
  1084. if (certIdList != "") {
  1085. where += " and b.Id in (" + certIdList + ")"
  1086. total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1087. }
  1088. //根据部门查询待办任务
  1089. var datainfo DataInfo
  1090. datainfo.Items = list
  1091. datainfo.CurrentItemCount = total
  1092. datainfo.PageIndex = page.CurrentPage
  1093. datainfo.ItemsPerPage = page.Size
  1094. this.Data["json"] = &datainfo
  1095. this.ServeJSON()
  1096. }
  1097. // @Title 获取字典列表
  1098. // @Description get user by token
  1099. // @Success 200 {object} map[string]interface{}
  1100. // @router /dictlist [get]
  1101. func (this *OilSupplierController) GetDictList() {
  1102. dictList := make(map[string]interface{})
  1103. dictSvc := items.GetItemsService(utils.DBE)
  1104. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1105. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1106. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1107. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1108. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1109. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1110. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1111. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1112. var userEntity userRole.Base_User
  1113. userSvc.GetEntityById(this.User.Id, &userEntity)
  1114. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1115. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1116. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1117. //获取我创建的所有公司
  1118. var list []supplier.OilSupplier
  1119. if this.User.IsCompanyUser == 1 {
  1120. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1121. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1122. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1123. dictList["CompanyNames"] = list
  1124. } else { //二级单位不用获取
  1125. dictList["CompanyNames"] = list
  1126. }
  1127. // 部门
  1128. orgsvc := organize.GetOrganizeService(utils.DBE)
  1129. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1130. //var dictCustomer []svccustomer.Customer
  1131. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1132. //dictList["EntrustCorp"] = &dictCustomer
  1133. //获得有审核权限的人员
  1134. var users []userRole.Base_RoleList
  1135. var auditWorkflow auditsetting.Base_OilAuditSetting
  1136. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1137. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1138. users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1139. dictList["Auditer"] = users
  1140. var datainfo DataInfo
  1141. datainfo.Items = dictList
  1142. this.Data["json"] = &datainfo
  1143. this.ServeJSON()
  1144. }
  1145. // @Title 获取字典列表By Status
  1146. // @Description get user by token
  1147. // @Success 200 {object} map[string]interface{}
  1148. // @router /dictlistbystatus/ [get]
  1149. func (this *OilSupplierController) GetDictListByStatus() {
  1150. //status := this.Ctx.Input.Param(":status")
  1151. status := this.GetString("status")
  1152. majorAduit := this.GetString("majorAduit")
  1153. dictList := make(map[string]interface{})
  1154. dictSvc := items.GetItemsService(utils.DBE)
  1155. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1156. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1157. orgsvc := organize.GetOrganizeService(utils.DBE)
  1158. svc := supplier.GetOilSupplierService(utils.DBE)
  1159. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1160. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1161. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1162. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1163. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1164. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1165. dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
  1166. var userEntity userRole.Base_User
  1167. userSvc.GetEntityById(this.User.Id, &userEntity)
  1168. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1169. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1170. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1171. //获取专业审批处室部门
  1172. var preorglist []organize.Base_Organizetree
  1173. //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1174. //topid := paramSvc.GetBaseparameterMessage("", "paramset", "HeadquartersID") // 总公司Id
  1175. ids := orgsvc.GetAllChildUnitById("0")
  1176. svc.GetProOrTreeList(ids, &preorglist)
  1177. dictList["ProOrgList"] = preorglist
  1178. var unitorglist []organize.Base_Organize
  1179. where := "Category='Unit' and ParentId in (100000001,100000176) and Id not in (100000004,100000003,100000002) "
  1180. orgsvc.GetEntities(&unitorglist, where)
  1181. dictList["UnitOrgList"] = unitorglist
  1182. //获取我创建的所有公司
  1183. var list []supplier.OilSupplier
  1184. if this.User.IsCompanyUser == 1 {
  1185. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1186. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1187. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1188. dictList["CompanyNames"] = list
  1189. } else { //二级单位不用获取
  1190. dictList["CompanyNames"] = list
  1191. }
  1192. // 部门
  1193. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1194. //var dictCustomer []svccustomer.Customer
  1195. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1196. //dictList["EntrustCorp"] = &dictCustomer
  1197. //获得有审核权限的人员
  1198. //var users []suppliercert.UserList
  1199. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1200. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1201. var users []userRole.Base_RoleList
  1202. if status == suppliercert.FIRST_TRIAL_STATUS {
  1203. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1204. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1205. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1206. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1207. certSrv.GetAuditUser(this.User.DepartmentId, workflow.SECOND_TRIAL, &users)
  1208. dictList["Auditer"] = users
  1209. } else if status == suppliercert.SECOND_TRIAL_STATUS {
  1210. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1211. } else if status == suppliercert.THIRD_TRIAL_STATUS {
  1212. //where := "OrganizeId=" + majorAduit + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1213. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1214. certSrv.GetAuditUser(majorAduit, workflow.SECOND_TRIAL, &users)
  1215. dictList["Auditer"] = users
  1216. } else if status == suppliercert.PROF_AUDIT_STATUS {
  1217. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.PROF_AUDIT + "'"
  1218. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1219. certSrv.GetAuditUser(this.User.DepartmentId, workflow.PROF_AUDIT, &users)
  1220. dictList["Auditer"] = users
  1221. } else if status == suppliercert.CENT_AUDIT_STATUS {
  1222. }
  1223. // 注册审批单位
  1224. var registermodel register.OilCorporateInfo
  1225. wherereg := "UserId=" + this.User.Id
  1226. svc.GetEntity(&registermodel, wherereg)
  1227. dictList["Register"] = registermodel
  1228. // 所有二级单位
  1229. var allunitorglist []organize.Base_Organize
  1230. where = "Category='Unit'"
  1231. orgsvc.GetEntities(&allunitorglist, where)
  1232. dictList["Allunitorglist"] = allunitorglist
  1233. var datainfo DataInfo
  1234. datainfo.Items = dictList
  1235. this.Data["json"] = &datainfo
  1236. this.ServeJSON()
  1237. }
  1238. // @Title 获取实体
  1239. // @Description 获取实体
  1240. // @Success 200 {object} supplier.OilSupplier
  1241. // @router /get/:id [get]
  1242. func (this *OilSupplierController) GetEntity() {
  1243. Id := this.Ctx.Input.Param(":id")
  1244. var model supplier.OilSupplier
  1245. svc := supplier.GetOilSupplierService(utils.DBE)
  1246. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1247. this.Data["json"] = &model
  1248. this.ServeJSON()
  1249. }
  1250. // @Title 获取实体
  1251. // @Description 获取实体
  1252. // @Success 200 {object} supplier.OilSupplier
  1253. // @router /getandcert/:certId [get]
  1254. func (this *OilSupplierController) GetEntityAndCert() {
  1255. Id := this.Ctx.Input.Param(":certId")
  1256. var model supplier.OilSupplierView
  1257. //svc := supplier.GetOilSupplierService(utils.DBE)
  1258. //svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1259. var sql string
  1260. sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, b.Step, b.WorkerTotal, b.ContractNum, b.UniversityNum, b.TechnicalNum, b.AboveProfNum,
  1261. b.MiddleProfNum, b.NationalRegNum, b.NationalCertTotal, b.DesignerTotal, b.SkillerTotal, b.InStyle, b.WorkflowId, b.Status, b.ThirdAudit, b.BusinessKey, b.AuditIndex ,b.ProcessKey from ` + OilSupplierName + ` a `
  1262. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  1263. sql += ` where b.Id ='` + Id + `'`
  1264. utils.DBE.SQL(sql).Get(&model)
  1265. this.Data["json"] = &model
  1266. this.ServeJSON()
  1267. }
  1268. // @Title 获取实体
  1269. // @Description 获取实体
  1270. // @Success 200 {object} supplier.OilSupplier
  1271. // @router /getbyname [get]
  1272. func (this *OilSupplierController) GetEntityByName() {
  1273. name := this.GetString("name")
  1274. typecode := this.GetString("typecode")
  1275. svc := supplier.GetOilSupplierService(utils.DBE)
  1276. var model supplier.OilSupplierApply
  1277. var sql string
  1278. sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
  1279. sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='`+typecode+`'`
  1280. sql += ` where a.SupplierName ='` + name + `'`
  1281. utils.DBE.SQL(sql).Get(&model)
  1282. if model.SupplierName==""{
  1283. var model2 register.OilCorporateInfo
  1284. svc.GetEntityByWhere(OilCorporateInfoName, "SupplierName='" + name + "'", &model2)
  1285. model2.Remark=""
  1286. model2.Id=0
  1287. if model2.SupplierName==""{
  1288. this.ServeJSON()
  1289. }else{
  1290. this.Data["json"] = &model2
  1291. this.ServeJSON()
  1292. }
  1293. }
  1294. this.Data["json"] = &model
  1295. this.ServeJSON()
  1296. }
  1297. // @Title 添加
  1298. // @Description 新增
  1299. // @Success 200 {object} controllers.Request
  1300. // @router /add [post]
  1301. func (this *OilSupplierController) AddEntity() {
  1302. var model supplier.OilSupplier
  1303. var modelCert suppliercert.OilSupplierCert
  1304. var modelCertVM suppliercert.OilSupplierVM
  1305. var jsonBlob = this.Ctx.Input.RequestBody
  1306. json.Unmarshal(jsonBlob, &model)
  1307. json.Unmarshal(jsonBlob, &modelCertVM)
  1308. serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1309. canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id, this.User.IsCompanyUser)
  1310. var errinfo ErrorDataInfo
  1311. if !canApply {
  1312. errinfo.Message = "添加失败!供方用户只能申请一次"
  1313. errinfo.Code = -1
  1314. this.Data["json"] = &errinfo
  1315. this.ServeJSON()
  1316. return
  1317. }
  1318. var list []supplier.OilSupplierView
  1319. service := supplier.GetOilSupplierService(utils.DBE)
  1320. service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1321. if len(list) > 0 {
  1322. errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1323. errinfo.Code = -1
  1324. this.Data["json"] = &errinfo
  1325. this.ServeJSON()
  1326. return
  1327. }
  1328. //if model.Id <= 0 {
  1329. // service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1330. // if len(list) > 0 {
  1331. // errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1332. // errinfo.Code = -1
  1333. // this.Data["json"] = &errinfo
  1334. // this.ServeJSON()
  1335. // return
  1336. // }
  1337. //} else {
  1338. // service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1339. // if len(list) > 0 {
  1340. // errinfo.Message = "添加失败! 已存在相关企业的信息,或与其他企业信息重复"
  1341. // errinfo.Code = -1
  1342. // this.Data["json"] = &errinfo
  1343. // this.ServeJSON()
  1344. // return
  1345. // }
  1346. //}
  1347. var session *xorm.Session
  1348. session = utils.DBE.NewSession()
  1349. svc := supplier.GetOilSupplierSession(session)
  1350. svcCert := suppliercert.GetOilSupplierCertSession(session)
  1351. model.CreateOn = time.Now()
  1352. model.CreateBy = this.User.Realname
  1353. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1354. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  1355. defer session.Close()
  1356. err := session.Begin()
  1357. if model.Id <= 0 {
  1358. _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
  1359. } else {
  1360. //判断基本信息是否可修改
  1361. updateCols := svc.GetUpdateCols(OilSupplierCertName, modelCertVM.SupplierTypeCode, model.Id)
  1362. err = svc.UpdateEntityBytbl(OilSupplierName, model.Id, &model, updateCols)
  1363. }
  1364. if err != nil {
  1365. session.Rollback()
  1366. }
  1367. modelCert.SupplierId = model.Id
  1368. modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
  1369. modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
  1370. modelCert.InStyle = modelCertVM.InStyle
  1371. modelCert.Step = 1 //企业信息保存完成
  1372. modelCert.CreateOn = time.Now()
  1373. modelCert.CreateBy = this.User.Realname
  1374. modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1375. _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
  1376. if err != nil {
  1377. session.Rollback()
  1378. }
  1379. // add Commit() after all actions
  1380. err = session.Commit()
  1381. if err == nil {
  1382. //新增
  1383. errinfo.Message = "添加成功!"
  1384. errinfo.Code = 0
  1385. errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
  1386. this.Data["json"] = &errinfo
  1387. this.ServeJSON()
  1388. } else {
  1389. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  1390. errinfo.Code = -1
  1391. this.Data["json"] = &errinfo
  1392. this.ServeJSON()
  1393. }
  1394. }
  1395. // @Title 修改实体
  1396. // @Description 修改实体
  1397. // @Success 200 {object} controllers.Request
  1398. // @router /update/:id/:type/:instyle [post]
  1399. func (this *OilSupplierController) UpdateEntity() {
  1400. id := this.Ctx.Input.Param(":id")
  1401. typeCode := this.Ctx.Input.Param(":type")
  1402. instyle := this.Ctx.Input.Param(":instyle")
  1403. var errinfo ErrorInfo
  1404. if id == "" {
  1405. errinfo.Message = "操作失败!请求信息不完整"
  1406. errinfo.Code = -2
  1407. this.Data["json"] = &errinfo
  1408. this.ServeJSON()
  1409. return
  1410. }
  1411. var model supplier.OilSupplier
  1412. var jsonBlob = this.Ctx.Input.RequestBody
  1413. json.Unmarshal(jsonBlob, &model)
  1414. var list []supplier.OilSupplierView
  1415. service := supplier.GetOilSupplierService(utils.DBE)
  1416. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1417. if len(list) > 0 {
  1418. errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
  1419. errinfo.Code = -1
  1420. this.Data["json"] = &errinfo
  1421. this.ServeJSON()
  1422. return
  1423. }
  1424. svc := supplier.GetOilSupplierService(utils.DBE)
  1425. model.ModifiedOn = time.Now()
  1426. model.ModifiedBy = this.User.Realname
  1427. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1428. //判断基本信息是否可修改
  1429. updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
  1430. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
  1431. if err == nil {
  1432. svc.DBE.Exec("update OilSupplierCert set Instyle="+instyle+" where SupplierId="+id+" and SupplierTypeCode="+typeCode+"")
  1433. errinfo.Message = "修改成功!"
  1434. errinfo.Code = 0
  1435. this.Data["json"] = &errinfo
  1436. this.ServeJSON()
  1437. } else {
  1438. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1439. errinfo.Code = -1
  1440. this.Data["json"] = &errinfo
  1441. this.ServeJSON()
  1442. }
  1443. }
  1444. // @Title 修改企业人员情况实体
  1445. // @Description 修改实体
  1446. // @Success 200 {object} controllers.Request
  1447. // @router /updatenumber/:id [post]
  1448. func (this *OilSupplierController) UpdateNumberEntity() {
  1449. idGroup := this.Ctx.Input.Param(":id")
  1450. //id := strings.Split(idGroup, "_")[0]
  1451. certId := strings.Split(idGroup, "_")[1]
  1452. var errinfo ErrorInfo
  1453. if certId == "" {
  1454. errinfo.Message = "操作失败!请求信息不完整"
  1455. errinfo.Code = -2
  1456. this.Data["json"] = &errinfo
  1457. this.ServeJSON()
  1458. return
  1459. }
  1460. var modelCert suppliercert.OilSupplierCert
  1461. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1462. var jsonBlob = this.Ctx.Input.RequestBody
  1463. json.Unmarshal(jsonBlob, &modelCert)
  1464. modelCert.ModifiedOn = time.Now()
  1465. modelCert.ModifiedBy = this.User.Realname
  1466. modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1467. colcerts := []string{
  1468. "Id",
  1469. "InStyle",
  1470. "WorkerTotal",
  1471. "ContractNum ",
  1472. "UniversityNum",
  1473. "TechnicalNum",
  1474. "AboveProfNum",
  1475. "MiddleProfNum",
  1476. "NationalRegNum",
  1477. "NationalCertTotal",
  1478. "DesignerTotal",
  1479. "SkillerTotal",
  1480. "ModifiedOn",
  1481. "ModifiedUserId",
  1482. "ModifiedBy",
  1483. }
  1484. // if modelCert.Step <= 2 {
  1485. // modelCert.Step = 2 //完成企业基本信息
  1486. // colcerts = append(colcerts, "Step")
  1487. // }
  1488. err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
  1489. if err == nil {
  1490. errinfo.Message = "保存成功!"
  1491. errinfo.Code = 0
  1492. this.Data["json"] = &errinfo
  1493. this.ServeJSON()
  1494. } else {
  1495. errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
  1496. errinfo.Code = -1
  1497. this.Data["json"] = &errinfo
  1498. this.ServeJSON()
  1499. }
  1500. }
  1501. // @Title 删除单条信息
  1502. // @Description
  1503. // @Success 200 {object} ErrorInfo
  1504. // @Failure 403 :id 为空
  1505. // @router /delete/:Id [delete]
  1506. func (this *OilSupplierController) DeleteEntity() {
  1507. Id := this.Ctx.Input.Param(":Id")
  1508. var errinfo ErrorInfo
  1509. if Id == "" {
  1510. errinfo.Message = "操作失败!请求信息不完整"
  1511. errinfo.Code = -2
  1512. this.Data["json"] = &errinfo
  1513. this.ServeJSON()
  1514. return
  1515. }
  1516. var model supplier.OilSupplier
  1517. var entityempty supplier.OilSupplier
  1518. svc := supplier.GetOilSupplierService(utils.DBE)
  1519. opdesc := "删除-" + Id
  1520. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  1521. if err == nil {
  1522. errinfo.Message = "删除成功"
  1523. errinfo.Code = 0
  1524. this.Data["json"] = &errinfo
  1525. this.ServeJSON()
  1526. } else {
  1527. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1528. errinfo.Code = -1
  1529. this.Data["json"] = &errinfo
  1530. this.ServeJSON()
  1531. }
  1532. }
  1533. // @Title 删除单条信息
  1534. // @Description
  1535. // @Success 200 {object} ErrorInfo
  1536. // @Failure 403 :id 为空
  1537. // @router /deleteall/:Id/:SupplierTypeCode [delete]
  1538. func (this *OilSupplierController) DeleteAllEntity() {
  1539. Id := this.Ctx.Input.Param(":Id")
  1540. SupplierTypeCode := this.Ctx.Input.Param(":SupplierTypeCode")
  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. svc := supplier.GetOilSupplierService(utils.DBE)
  1550. err:=svc.DeleteEntityBytbl(OilSupplierCertName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1551. err =svc.DeleteEntityBytbl(OilSupplierCert2FileName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1552. err =svc.DeleteEntityBytbl(OilSupplierFileName,"SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1553. var model1 suppliercertsub.OilSupplierCert2File
  1554. count1, _ := svc.GetCount(&model1, "SupplierId="+Id)
  1555. if count1==0{
  1556. err=svc.DeleteEntityBytbl(OilSupplierFileName,"SupplierId="+Id)
  1557. }
  1558. var model2 suppliercert.OilSupplierCert
  1559. count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
  1560. if count2==0{
  1561. err=svc.DeleteEntityBytbl(OilSupplierName,"Id="+Id)
  1562. }
  1563. if err == nil {
  1564. errinfo.Message = "删除成功"
  1565. errinfo.Code = 0
  1566. this.Data["json"] = &errinfo
  1567. this.ServeJSON()
  1568. } else {
  1569. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1570. errinfo.Code = -1
  1571. this.Data["json"] = &errinfo
  1572. this.ServeJSON()
  1573. }
  1574. }
  1575. // @Title 判断是否可以申请准入
  1576. // @Description
  1577. // @Success 200 {string} Count
  1578. // @Failure 403 :id 为空
  1579. // @router /iscanapply/:type [get]
  1580. func (this *OilSupplierController) IsCanApply() {
  1581. Type := this.Ctx.Input.Param(":type")
  1582. var errinfo ErrorInfo
  1583. if Type == "" {
  1584. errinfo.Message = "操作失败!请求信息不完整"
  1585. errinfo.Code = -2
  1586. this.Data["json"] = &errinfo
  1587. this.ServeJSON()
  1588. return
  1589. }
  1590. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1591. var registerUser register.OilCorporateInfo
  1592. sql := " UserName='" + this.User.Username + "'"
  1593. svc.GetEntity(&registerUser,sql)
  1594. canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
  1595. if canApply {
  1596. errinfo.Message = "无申请记录,可以申请"
  1597. errinfo.Code = 0
  1598. this.Data["json"] = &errinfo
  1599. this.ServeJSON()
  1600. } else {
  1601. errinfo.Message = "供方用户只能申请一次"
  1602. errinfo.Code = -1
  1603. this.Data["json"] = &errinfo
  1604. this.ServeJSON()
  1605. }
  1606. }
  1607. // @Title 判断是否可以修改供方企业信息
  1608. // @Description
  1609. // @Success 200 {string} Count
  1610. // @Failure 403 :id 为空
  1611. // @router /iscanupdatesupplier/:supplierid [get]
  1612. func (this *OilSupplierController) CanUpdateSupplier() {
  1613. supplierId := this.Ctx.Input.Param(":supplierid")
  1614. var errinfo ErrorInfo
  1615. if supplierId == "" {
  1616. errinfo.Message = "操作失败!请求信息不完整"
  1617. errinfo.Code = -2
  1618. this.Data["json"] = &errinfo
  1619. this.ServeJSON()
  1620. return
  1621. }
  1622. Id, _ := strconv.Atoi(supplierId)
  1623. svc := supplier.GetOilSupplierService(utils.DBE)
  1624. canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id)
  1625. if canUpdate {
  1626. errinfo.Message = "可以修改"
  1627. errinfo.Code = 0
  1628. this.Data["json"] = &errinfo
  1629. this.ServeJSON()
  1630. } else {
  1631. errinfo.Message = "此供方已经提交准入申请,不可修改"
  1632. errinfo.Code = -1
  1633. this.Data["json"] = &errinfo
  1634. this.ServeJSON()
  1635. }
  1636. }
  1637. // @Title 获取二级审核人员
  1638. // @Description 获取二级审核人员
  1639. // @router /getauditerbydept/:deptId [get]
  1640. func (this *OilSupplierController) GetAuditerByDept() {
  1641. Id := this.Ctx.Input.Param(":deptId")
  1642. auditstepcode := this.GetString("auditstepcode")
  1643. svc := organize.GetOrganizeService(utils.DBE)
  1644. unitId := svc.GetMyUnitDepartmentId(Id)
  1645. //ids := svc.GetAllChildById(unitId)
  1646. //
  1647. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1648. //var users []userRole.Base_RoleList
  1649. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1650. var userlist []userRole.Base_User
  1651. var setting auditsetting.Base_OilAuditSetting
  1652. usvc := userRole.GetUserService(utils.DBE)
  1653. where := "AuditStepCode='" + auditstepcode + "'"
  1654. svc.GetEntity(&setting, where)
  1655. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1656. tempstr := strings.Join(ids, ",")
  1657. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1658. userIds = strings.Trim(userIds, ",")
  1659. if userIds != "" {
  1660. where := "Id in (" + userIds + ")" + " and UnitId=" + unitId
  1661. svc.GetEntities(&userlist, where)
  1662. }
  1663. var datainfo ErrorDataInfo
  1664. datainfo.Item = userlist
  1665. this.Data["json"] = &datainfo
  1666. this.ServeJSON()
  1667. }
  1668. // @Title 获取二级初审人员
  1669. // @Description 获取二级初审人员
  1670. // @router /getfirauditerbydept/:deptId [get]
  1671. func (this *OilSupplierController) GetFirAuditerByDept() {
  1672. Id := this.Ctx.Input.Param(":deptId")
  1673. auditstepcode := this.GetString("auditstepcode")
  1674. var userlist []userRole.Base_User
  1675. var setting auditsetting.Base_OilAuditSetting
  1676. svc := userRole.GetUserService(utils.DBE)
  1677. where := "AuditStepCode='" + auditstepcode + "'"
  1678. svc.GetEntity(&setting, where)
  1679. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1680. tempstr := strings.Join(ids, ",")
  1681. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1682. userIds = strings.Trim(userIds, ",")
  1683. if userIds != "" {
  1684. where := "Id in (" + userIds + ")" + "and UnitId=" + Id
  1685. svc.GetEntities(&userlist, where)
  1686. }
  1687. //svc := organize.GetOrganizeService(utils.DBE)
  1688. //
  1689. //ids := svc.GetAllChildById(Id)
  1690. //
  1691. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1692. //var users []userRole.Base_RoleList
  1693. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1694. var datainfo ErrorDataInfo
  1695. datainfo.Item = userlist
  1696. this.Data["json"] = &datainfo
  1697. this.ServeJSON()
  1698. }
  1699. // @Title 获取二级复审人员根据初审人员
  1700. // @Description 获取二级复审人员根据初审人员
  1701. // @router /getauditerbyfirst/:firstId [get]
  1702. func (this *OilSupplierController) GetAuditerByFist() {
  1703. Id := this.Ctx.Input.Param(":firstId")
  1704. auditstepcode := this.GetString("auditstepcode")
  1705. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1706. //orgSrv := organize.GetOrganizeService(utils.DBE)
  1707. var userentity userRole.Base_User
  1708. certSrv.GetEntityById(Id, &userentity)
  1709. var userlist []userRole.Base_User
  1710. var setting auditsetting.Base_OilAuditSetting
  1711. svc := userRole.GetUserService(utils.DBE)
  1712. where := "AuditStepCode='" + auditstepcode + "'"
  1713. svc.GetEntity(&setting, where)
  1714. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1715. tempstr := strings.Join(ids, ",")
  1716. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1717. userIds = strings.Trim(userIds, ",")
  1718. if userIds != "" {
  1719. where := "Id in (" + userIds + ")" + "and UnitId=" + strconv.Itoa(userentity.UnitId)
  1720. svc.GetEntities(&userlist, where)
  1721. }
  1722. //svc := organize.GetOrganizeService(utils.DBE)
  1723. //unitId := svc.GetMyUnitDepartmentId(userentity.Departmentid)
  1724. //ids := svc.GetAllChildById(unitId)
  1725. ////depId := strings.Split(userentity.Superior,",")
  1726. //var users []userRole.Base_RoleList
  1727. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1728. var datainfo ErrorDataInfo
  1729. datainfo.Item = userlist
  1730. this.Data["json"] = &datainfo
  1731. this.ServeJSON()
  1732. }
  1733. // @Title 获取二级初审人员(不需要验证登录)
  1734. // @Description 获取二级初审人员(不需要验证登录)
  1735. // @router /getauditerbydeptandnologin [get]
  1736. func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
  1737. Id := this.GetString("deptId")
  1738. auditstepcode := this.GetString("auditstepcode")
  1739. var userlist []userRole.Base_User
  1740. var setting auditsetting.Base_OilAuditSetting
  1741. svc := userRole.GetUserService(utils.DBE)
  1742. where := "AuditStepCode='" + auditstepcode + "'"
  1743. svc.GetEntity(&setting, where)
  1744. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1745. tempstr := strings.Join(ids, ",")
  1746. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1747. userIds = strings.Trim(userIds, ",")
  1748. if userIds != "" {
  1749. where := "Id in (" + userIds + ")" + "and UnitId=" + Id
  1750. svc.GetEntities(&userlist, where)
  1751. }
  1752. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1753. //var users []userRole.Base_RoleList
  1754. //certSrv.GetAuditUser(Id, auditstepcode, &users)
  1755. // certSrv.GetAuditUserByNoLogin(Id, &users)
  1756. var datainfo ErrorDataInfo
  1757. datainfo.Item = userlist
  1758. this.Data["json"] = &datainfo
  1759. this.ServeJSON()
  1760. }
  1761. // @Title
  1762. // @Description
  1763. // @router /getjurisdiction [get]
  1764. func (this *OilSupplierController) GetJurisdiction() {
  1765. svcPerm := permission.GetPermissionService(utils.DBE)
  1766. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_delete")
  1767. var datainfo ErrorDataInfo
  1768. datainfo.Item = isauth
  1769. this.Data["json"] = &datainfo
  1770. this.ServeJSON()
  1771. }