supplier.go 74 KB

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