supplier.go 66 KB

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