supplier.go 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  4. "dashoo.cn/backend/api/business/oilsupplier/supplierscenefile"
  5. "dashoo.cn/backend/api/business/register"
  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. ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_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_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  618. if len(strings.Trim(ids, ",")) > 0 {
  619. certIdList += strings.Trim(ids, ",") + ","
  620. }
  621. //ids = actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  622. //if len(strings.Trim(ids, ",")) > 0 {
  623. // certIdList += strings.Trim(ids, ",")+ ","
  624. //}
  625. //
  626. //ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  627. //if len(strings.Trim(ids, ",")) > 0 {
  628. // certIdList += strings.Trim(ids, ",")+ ","
  629. //}
  630. //
  631. //ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  632. //if len(strings.Trim(ids, ",")) > 0 {
  633. // certIdList += strings.Trim(ids, ",")+ ","
  634. //}
  635. certIdList = strings.Trim(certIdList, ",")
  636. certIdarr := strings.Split(certIdList, ",")
  637. for i, item := range certIdarr {
  638. idx := strings.Index(item, "-")
  639. if idx >= 0 {
  640. certIdarr[i] = strings.Split(item, "-")[0]
  641. }
  642. }
  643. certIdList = strings.Join(certIdarr, ",")
  644. if certIdList != "" {
  645. where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
  646. } else {
  647. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  648. }
  649. } else {
  650. //where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  651. }
  652. }
  653. svc := supplier.GetOilSupplierService(utils.DBE)
  654. var list []supplier.OilSupplierView
  655. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  656. var datainfo DataInfo
  657. datainfo.Items = list
  658. datainfo.CurrentItemCount = total
  659. datainfo.PageIndex = page.CurrentPage
  660. datainfo.ItemsPerPage = page.Size
  661. this.Data["json"] = &datainfo
  662. this.ServeJSON()
  663. }
  664. // @Title 企业入库列表
  665. // @Description get user by token
  666. // @Success 200 {object} []supplier.OilSupplier
  667. // @router /storelist [get]
  668. func (this *OilSupplierController) GetJoinStoreEntityList() {
  669. //获取分页信息
  670. page := this.GetPageInfoForm()
  671. where := " 1=1 "
  672. orderby := "Id"
  673. asc := false
  674. Order := this.GetString("Order")
  675. Prop := this.GetString("Prop")
  676. if Order != "" && Prop != "" {
  677. orderby = Prop
  678. if Order == "asc" {
  679. asc = true
  680. }
  681. }
  682. SupplierName := this.GetString("SupplierName")
  683. SupplierTypeName := this.GetString("SupplierTypeName")
  684. CreateOn := this.GetString("CreateOn")
  685. SupplierTypeCode := this.GetString("SupplierTypeCode")
  686. OperType := this.GetString("OperType")
  687. SpecTypeCode := this.GetString("SpecTypeCode")
  688. Country := this.GetString("Country")
  689. InStyle := this.GetString("InStyle")
  690. MgrUnit := this.GetString("MgrUnit")
  691. PACNumber := this.GetString("PACNumber")
  692. CommercialNo := this.GetString("CommercialNo")
  693. Province := this.GetString("Province")
  694. City := this.GetString("City")
  695. Street := this.GetString("Street")
  696. Address := this.GetString("Address")
  697. LinkProvince := this.GetString("LinkProvince")
  698. LinkCity := this.GetString("LinkCity")
  699. LinkStreet := this.GetString("LinkStreet")
  700. LinkAddress := this.GetString("LinkAddress")
  701. LegalPerson := this.GetString("LegalPerson")
  702. ContactName := this.GetString("ContactName")
  703. CompanyType := this.GetString("CompanyType")
  704. SetupTime := this.GetString("SetupTime")
  705. RegCapital1 := this.GetString("RegCapital1")
  706. RegCapital2 := this.GetString("RegCapital2")
  707. BusinessScope := this.GetString("BusinessScope")
  708. if SupplierName != "" {
  709. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  710. }
  711. if SupplierTypeName != "" {
  712. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  713. }
  714. if CreateOn != "" {
  715. dates := strings.Split(CreateOn, ",")
  716. if len(dates) == 2 {
  717. minDate := dates[0]
  718. maxDate := dates[1]
  719. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  720. }
  721. }
  722. if SupplierTypeCode != "" {
  723. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  724. }
  725. if OperType != "" {
  726. where = where + " and a.OperType like '%" + OperType + "%'"
  727. }
  728. if SpecTypeCode != "" {
  729. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  730. }
  731. if Country != "" {
  732. where = where + " and a.Country like '%" + Country + "%'"
  733. }
  734. if InStyle != "" {
  735. where = where + " and b.InStyle ='" + InStyle + "'"
  736. }
  737. if MgrUnit != "" {
  738. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  739. }
  740. if PACNumber != "" {
  741. where = where + " and a.PACNumber ='" + PACNumber + "'"
  742. }
  743. if CommercialNo != "" {
  744. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  745. }
  746. if Province != "" {
  747. where = where + " and a.Province ='" + Province + "'"
  748. }
  749. if City != "" {
  750. where = where + " and a.City ='" + City + "'"
  751. }
  752. if Street != "" {
  753. where = where + " and a.Street ='" + Street + "'"
  754. }
  755. if Address != "" {
  756. where = where + " and a.Address ='" + Address + "'"
  757. }
  758. if LinkProvince != "" {
  759. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  760. }
  761. if LinkCity != "" {
  762. where = where + " and a.LinkCity ='" + LinkCity + "'"
  763. }
  764. if LinkStreet != "" {
  765. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  766. }
  767. if LinkAddress != "" {
  768. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  769. }
  770. if LegalPerson != "" {
  771. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  772. }
  773. if ContactName != "" {
  774. where = where + " and a.ContactName ='" + ContactName + "'"
  775. }
  776. if CompanyType != "" {
  777. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  778. }
  779. if SetupTime != "" {
  780. where = where + " and a.SetupTime ='" + SetupTime + "'"
  781. }
  782. //注册资金范围
  783. if RegCapital1 != "" {
  784. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  785. }
  786. if RegCapital2 != "" {
  787. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  788. }
  789. if BusinessScope != "" {
  790. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  791. }
  792. status := this.GetString("Status")
  793. if status != "" {
  794. where = where + " and b.Status='" + status + "'"
  795. }
  796. //企业用户只看自己的数据记录
  797. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  798. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  799. if extOrganizeId == this.User.DepartmentId {
  800. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  801. }*/
  802. //企业用户必须加创建人条件
  803. if this.User.IsCompanyUser == 1 {
  804. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  805. }
  806. svc := supplier.GetOilSupplierService(utils.DBE)
  807. var list []supplier.OilSupplierView
  808. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  809. var datainfo DataInfo
  810. datainfo.Items = list
  811. datainfo.CurrentItemCount = total
  812. datainfo.PageIndex = page.CurrentPage
  813. datainfo.ItemsPerPage = page.Size
  814. this.Data["json"] = &datainfo
  815. this.ServeJSON()
  816. }
  817. // @Title 获取列表
  818. // @Description get user by token
  819. // @Success 200 {object} []supplier.OilSupplierView
  820. // @router /mytasks [get]
  821. func (this *OilSupplierController) GetMyTaskEntityList() {
  822. //获取分页信息
  823. page := this.GetPageInfoForm()
  824. where := " 1=1 "
  825. orderby := "Id"
  826. asc := false
  827. Order := this.GetString("Order")
  828. //Statustype := this.GetString("Statustype")
  829. //if Statustype != "" {
  830. // where = " 1=1 and b.Status =" + Statustype
  831. //}
  832. where = where + " and b.Status>0"
  833. Prop := this.GetString("Prop")
  834. if Order != "" && Prop != "" {
  835. orderby = Prop
  836. if Order == "asc" {
  837. asc = true
  838. }
  839. }
  840. Id := this.GetString("Id")
  841. SupplierName := this.GetString("SupplierName")
  842. OilCertificateNo := this.GetString("OilCertificateNo")
  843. Grade := this.GetString("Grade")
  844. MgrUnit := this.GetString("MgrUnit")
  845. OperType := this.GetString("OperType")
  846. Country := this.GetString("Country")
  847. MaunAgent := this.GetString("MaunAgent")
  848. ConstructTeam := this.GetString("ConstructTeam")
  849. CommercialNo := this.GetString("CommercialNo")
  850. OrganCode := this.GetString("OrganCode")
  851. CountryTaxNo := this.GetString("CountryTaxNo")
  852. LocalTaxNo := this.GetString("LocalTaxNo")
  853. Address := this.GetString("Address")
  854. Province := this.GetString("Province")
  855. City := this.GetString("City")
  856. Street := this.GetString("Street")
  857. HouseNo := this.GetString("HouseNo")
  858. ZipCode := this.GetString("ZipCode")
  859. QualitySystemCert := this.GetString("QualitySystemCert")
  860. ProductQualityCert := this.GetString("ProductQualityCert")
  861. MaunLicense := this.GetString("MaunLicense")
  862. QualifCert := this.GetString("QualifCert")
  863. QualifCertLevel := this.GetString("QualifCertLevel")
  864. SafetyLicense := this.GetString("SafetyLicense")
  865. TechServiceLic := this.GetString("TechServiceLic")
  866. TJInNotify := this.GetString("TJInNotify")
  867. SpecIndustryCert := this.GetString("SpecIndustryCert")
  868. LegalPerson := this.GetString("LegalPerson")
  869. CategoryCode := this.GetString("CategoryCode")
  870. CategoryName := this.GetString("CategoryName")
  871. RegCapital := this.GetString("RegCapital")
  872. Currency := this.GetString("Currency")
  873. ContactName := this.GetString("ContactName")
  874. CompanyType := this.GetString("CompanyType")
  875. SetupTime := this.GetString("SetupTime")
  876. DepositBank := this.GetString("DepositBank")
  877. BankAccount := this.GetString("BankAccount")
  878. EMail := this.GetString("EMail")
  879. BankCreditRating := this.GetString("BankCreditRating")
  880. Mobile := this.GetString("Mobile")
  881. Telphone := this.GetString("Telphone")
  882. Fax := this.GetString("Fax")
  883. CompanyTel := this.GetString("CompanyTel")
  884. QQ := this.GetString("QQ")
  885. CompanyUrl := this.GetString("CompanyUrl")
  886. SpecSupplier := this.GetString("SpecSupplier")
  887. SpecTypeCode := this.GetString("SpecTypeCode")
  888. SpecTypeName := this.GetString("SpecTypeName")
  889. Remark := this.GetString("Remark")
  890. CreateOn := this.GetString("CreateOn")
  891. SupplierTypeCode := this.GetString("SupplierTypeCode")
  892. if Id != "" {
  893. where = where + " and a.Id like '%" + Id + "%'"
  894. }
  895. if SupplierName != "" {
  896. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  897. }
  898. if OilCertificateNo != "" {
  899. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  900. }
  901. if Grade != "" {
  902. where = where + " and a.Grade like '%" + Grade + "%'"
  903. }
  904. if MgrUnit != "" {
  905. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  906. }
  907. if OperType != "" {
  908. where = where + " and a.OperType like '%" + OperType + "%'"
  909. }
  910. if Country != "" {
  911. where = where + " and a.Country like '%" + Country + "%'"
  912. }
  913. if MaunAgent != "" {
  914. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  915. }
  916. if ConstructTeam != "" {
  917. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  918. }
  919. if CommercialNo != "" {
  920. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  921. }
  922. if OrganCode != "" {
  923. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  924. }
  925. if CountryTaxNo != "" {
  926. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  927. }
  928. if LocalTaxNo != "" {
  929. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  930. }
  931. if Address != "" {
  932. where = where + " and a.Address like '%" + Address + "%'"
  933. }
  934. if Province != "" {
  935. where = where + " and a.Province like '%" + Province + "%'"
  936. }
  937. if City != "" {
  938. where = where + " and a.City like '%" + City + "%'"
  939. }
  940. if Street != "" {
  941. where = where + " and a.Street like '%" + Street + "%'"
  942. }
  943. if HouseNo != "" {
  944. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  945. }
  946. if ZipCode != "" {
  947. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  948. }
  949. if QualitySystemCert != "" {
  950. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  951. }
  952. if ProductQualityCert != "" {
  953. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  954. }
  955. if MaunLicense != "" {
  956. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  957. }
  958. if QualifCert != "" {
  959. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  960. }
  961. if QualifCertLevel != "" {
  962. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  963. }
  964. if SafetyLicense != "" {
  965. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  966. }
  967. if TechServiceLic != "" {
  968. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  969. }
  970. if TJInNotify != "" {
  971. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  972. }
  973. if SpecIndustryCert != "" {
  974. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  975. }
  976. if LegalPerson != "" {
  977. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  978. }
  979. if CategoryCode != "" {
  980. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  981. }
  982. if CategoryName != "" {
  983. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  984. }
  985. if RegCapital != "" {
  986. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  987. }
  988. if Currency != "" {
  989. where = where + " and a.Currency like '%" + Currency + "%'"
  990. }
  991. if ContactName != "" {
  992. where = where + " and a.ContactName like '%" + ContactName + "%'"
  993. }
  994. if CompanyType != "" {
  995. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  996. }
  997. if SetupTime != "" {
  998. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  999. }
  1000. if DepositBank != "" {
  1001. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  1002. }
  1003. if BankAccount != "" {
  1004. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  1005. }
  1006. if EMail != "" {
  1007. where = where + " and a.EMail like '%" + EMail + "%'"
  1008. }
  1009. if BankCreditRating != "" {
  1010. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  1011. }
  1012. if Mobile != "" {
  1013. where = where + " and a.Mobile like '%" + Mobile + "%'"
  1014. }
  1015. if Telphone != "" {
  1016. where = where + " and a.Telphone like '%" + Telphone + "%'"
  1017. }
  1018. if Fax != "" {
  1019. where = where + " and a.Fax like '%" + Fax + "%'"
  1020. }
  1021. if CompanyTel != "" {
  1022. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  1023. }
  1024. if QQ != "" {
  1025. where = where + " and a.QQ like '%" + QQ + "%'"
  1026. }
  1027. if CompanyUrl != "" {
  1028. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  1029. }
  1030. if SpecSupplier != "" {
  1031. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  1032. }
  1033. if SpecTypeCode != "" {
  1034. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  1035. }
  1036. if SpecTypeName != "" {
  1037. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  1038. }
  1039. if Remark != "" {
  1040. where = where + " and a.Remark like '%" + Remark + "%'"
  1041. }
  1042. if CreateOn != "" {
  1043. dates := strings.Split(CreateOn, ",")
  1044. if len(dates) == 2 {
  1045. minDate := dates[0]
  1046. maxDate := dates[1]
  1047. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1048. }
  1049. }
  1050. if SupplierTypeCode != "" {
  1051. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1052. }
  1053. //找出待办任务
  1054. actisvc := workflow.GetActivitiService(utils.DBE)
  1055. var certIdList string
  1056. str := actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  1057. if str != "" {
  1058. certIdList = str
  1059. certIdList = certIdList + ","
  1060. }
  1061. str = actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  1062. if str != "" {
  1063. certIdList = fmt.Sprintf("%s %s", certIdList, str)
  1064. certIdList = certIdList + ","
  1065. }
  1066. str = actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  1067. if str != "" {
  1068. certIdList = fmt.Sprintf("%s %s", certIdList, str)
  1069. certIdList = certIdList + ","
  1070. }
  1071. //if actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1072. // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1073. // certIdList = certIdList + ","
  1074. //}
  1075. //if actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1076. // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1077. // certIdList = certIdList + ","
  1078. //}
  1079. //if actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  1080. // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id))
  1081. //}
  1082. certIdList = strings.Trim(certIdList, ",")
  1083. certIdarr := strings.Split(certIdList, ",")
  1084. for i, item := range certIdarr {
  1085. idx := strings.Index(item, "-")
  1086. if idx >= 0 {
  1087. certIdarr[i] = strings.Split(item, "-")[0]
  1088. }
  1089. }
  1090. certIdList = strings.Join(certIdarr, ",")
  1091. var list []supplier.OilSupplierView
  1092. svc := supplier.GetOilSupplierService(utils.DBE)
  1093. var total int64 = 0
  1094. if (certIdList != "") {
  1095. where += " and b.Id in (" + certIdList + ")"
  1096. total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1097. }
  1098. //根据部门查询待办任务
  1099. var datainfo DataInfo
  1100. datainfo.Items = list
  1101. datainfo.CurrentItemCount = total
  1102. datainfo.PageIndex = page.CurrentPage
  1103. datainfo.ItemsPerPage = page.Size
  1104. this.Data["json"] = &datainfo
  1105. this.ServeJSON()
  1106. }
  1107. // @Title 获取字典列表
  1108. // @Description get user by token
  1109. // @Success 200 {object} map[string]interface{}
  1110. // @router /dictlist [get]
  1111. func (this *OilSupplierController) GetDictList() {
  1112. dictList := make(map[string]interface{})
  1113. dictSvc := items.GetItemsService(utils.DBE)
  1114. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1115. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1116. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1117. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1118. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1119. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1120. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1121. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1122. var userEntity userRole.Base_User
  1123. userSvc.GetEntityById(this.User.Id, &userEntity)
  1124. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1125. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1126. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1127. //获取我创建的所有公司
  1128. var list []supplier.OilSupplier
  1129. if this.User.IsCompanyUser == 1 {
  1130. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1131. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1132. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1133. dictList["CompanyNames"] = list
  1134. } else { //二级单位不用获取
  1135. dictList["CompanyNames"] = list
  1136. }
  1137. // 部门
  1138. orgsvc := organize.GetOrganizeService(utils.DBE)
  1139. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1140. //var dictCustomer []svccustomer.Customer
  1141. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1142. //dictList["EntrustCorp"] = &dictCustomer
  1143. //获得有审核权限的人员
  1144. var users []userRole.Base_RoleList
  1145. var auditWorkflow auditsetting.Base_OilAuditSetting
  1146. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1147. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1148. users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1149. dictList["Auditer"] = users
  1150. var datainfo DataInfo
  1151. datainfo.Items = dictList
  1152. this.Data["json"] = &datainfo
  1153. this.ServeJSON()
  1154. }
  1155. // @Title 获取字典列表By Status
  1156. // @Description get user by token
  1157. // @Success 200 {object} map[string]interface{}
  1158. // @router /dictlistbystatus/ [get]
  1159. func (this *OilSupplierController) GetDictListByStatus() {
  1160. //status := this.Ctx.Input.Param(":status")
  1161. status := this.GetString("status")
  1162. majorAduit := this.GetString("majorAduit")
  1163. addId := this.GetString("addId")
  1164. dictList := make(map[string]interface{})
  1165. dictSvc := items.GetItemsService(utils.DBE)
  1166. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1167. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1168. orgsvc := organize.GetOrganizeService(utils.DBE)
  1169. svc := supplier.GetOilSupplierService(utils.DBE)
  1170. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1171. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1172. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1173. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1174. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1175. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1176. dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
  1177. var userEntity userRole.Base_User
  1178. userSvc.GetEntityById(this.User.Id, &userEntity)
  1179. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1180. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1181. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1182. //获取专业审批处室部门
  1183. var preorglist []organize.Base_Organizetree
  1184. //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1185. //topid := paramSvc.GetBaseparameterMessage("", "paramset", "HeadquartersID") // 总公司Id
  1186. ids := orgsvc.GetAllChildUnitById("0")
  1187. svc.GetProOrTreeList(ids, &preorglist)
  1188. dictList["ProOrgList"] = preorglist
  1189. var unitorglist []organize.Base_Organize
  1190. where := "Category='Unit'and Id not in (100000004,100000003,100000002) "
  1191. orgsvc.GetEntities(&unitorglist, where)
  1192. dictList["UnitOrgList"] = unitorglist
  1193. //获取我创建的所有公司
  1194. var list []supplier.OilSupplier
  1195. if this.User.IsCompanyUser == 1 {
  1196. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1197. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1198. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1199. dictList["CompanyNames"] = list
  1200. } else { //二级单位不用获取
  1201. dictList["CompanyNames"] = list
  1202. }
  1203. // 部门
  1204. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1205. //var dictCustomer []svccustomer.Customer
  1206. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1207. //dictList["EntrustCorp"] = &dictCustomer
  1208. //获得有审核权限的人员
  1209. //var users []suppliercert.UserList
  1210. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1211. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1212. var users []userRole.Base_RoleList
  1213. if status == suppliercert.FIRST_TRIAL_STATUS {
  1214. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1215. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1216. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1217. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1218. certSrv.GetAuditUser(this.User.DepartmentId, workflow.SECOND_TRIAL, &users)
  1219. dictList["Auditer"] = users
  1220. } else if status == suppliercert.SECOND_TRIAL_STATUS {
  1221. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1222. } else if status == suppliercert.THIRD_TRIAL_STATUS {
  1223. //where := "OrganizeId=" + majorAduit + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1224. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1225. certSrv.GetAuditUser(majorAduit, workflow.SECOND_TRIAL, &users)
  1226. dictList["Auditer"] = users
  1227. } else if status == suppliercert.PROF_AUDIT_STATUS {
  1228. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.PROF_AUDIT + "'"
  1229. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1230. certSrv.GetAuditUser(this.User.DepartmentId, workflow.PROF_AUDIT, &users)
  1231. dictList["Auditer"] = users
  1232. } else if status == suppliercert.CENT_AUDIT_STATUS {
  1233. }
  1234. // 注册审批单位
  1235. var registermodel register.OilCorporateInfo
  1236. wherereg := "UserId=" + this.User.Id
  1237. svc.GetEntity(&registermodel, wherereg)
  1238. dictList["Register"] = registermodel
  1239. // 所有二级单位
  1240. var allunitorglist []organize.Base_Organize
  1241. where = "Category='Unit'"
  1242. orgsvc.GetEntities(&allunitorglist, where)
  1243. dictList["Allunitorglist"] = allunitorglist
  1244. // 管理单位
  1245. var suppliermode supplier.OilSupplier
  1246. orgsvc.GetEntityById(addId, &suppliermode)
  1247. if suppliermode.MgrUnit == supplier.MGRUNIT {
  1248. dictList["MgrUnit"] = true
  1249. } else {
  1250. dictList["MgrUnit"] = false
  1251. }
  1252. var datainfo DataInfo
  1253. datainfo.Items = dictList
  1254. this.Data["json"] = &datainfo
  1255. this.ServeJSON()
  1256. }
  1257. // @Title 获取实体
  1258. // @Description 获取实体
  1259. // @Success 200 {object} supplier.OilSupplier
  1260. // @router /get/:id [get]
  1261. func (this *OilSupplierController) GetEntity() {
  1262. Id := this.Ctx.Input.Param(":id")
  1263. var model supplier.OilSupplier
  1264. svc := supplier.GetOilSupplierService(utils.DBE)
  1265. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1266. this.Data["json"] = &model
  1267. this.ServeJSON()
  1268. }
  1269. // @Title 获取实体
  1270. // @Description 获取实体
  1271. // @Success 200 {object} supplier.OilSupplier
  1272. // @router /getandcert/:certId [get]
  1273. func (this *OilSupplierController) GetEntityAndCert() {
  1274. Id := this.Ctx.Input.Param(":certId")
  1275. var model supplier.OilSupplierView
  1276. //svc := supplier.GetOilSupplierService(utils.DBE)
  1277. //svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1278. var sql string
  1279. 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,
  1280. 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 `
  1281. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  1282. sql += ` where b.Id ='` + Id + `'`
  1283. utils.DBE.SQL(sql).Get(&model)
  1284. this.Data["json"] = &model
  1285. this.ServeJSON()
  1286. }
  1287. // @Title 获取实体
  1288. // @Description 获取实体
  1289. // @Success 200 {object} supplier.OilSupplier
  1290. // @router /getbyname [get]
  1291. func (this *OilSupplierController) GetEntityByName() {
  1292. name := this.GetString("name")
  1293. typecode := this.GetString("typecode")
  1294. svc := supplier.GetOilSupplierService(utils.DBE)
  1295. var model supplier.OilSupplierApply
  1296. var datainfo ErrorDataInfo
  1297. var sqlsus string
  1298. sqlsus = `select 1 from ` + OilSupplierName + ` a `
  1299. sqlsus += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id`
  1300. sqlsus += ` where a.SupplierName ='` + name + `' and b.InFlag='2' and b.SupplierTypeCode='` + typecode + `'`
  1301. var tempMap []map[string]string
  1302. tempMap, _ = svc.DBE.QueryString(sqlsus)
  1303. if tempMap != nil && tempMap[0]["1"] != "" {
  1304. datainfo.Code = -1
  1305. this.Data["json"] = &datainfo
  1306. this.ServeJSON()
  1307. } else {
  1308. var sql string
  1309. sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
  1310. sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='` + typecode + `'`
  1311. sql += ` where a.SupplierName ='` + name + `'`
  1312. utils.DBE.SQL(sql).Get(&model)
  1313. if model.SupplierName == "" {
  1314. var model2 register.OilCorporateInfo
  1315. svc.GetEntityByWhere(OilCorporateInfoName, "SupplierName='"+name+"' and CheckStatus='11'", &model2)
  1316. model2.Remark = ""
  1317. model2.Id = 0
  1318. if model2.SupplierName == "" {
  1319. datainfo.Code = -2
  1320. this.Data["json"] = &datainfo
  1321. this.ServeJSON()
  1322. } else {
  1323. datainfo.Code = 0
  1324. datainfo.Item = model2
  1325. this.Data["json"] = &datainfo
  1326. this.ServeJSON()
  1327. }
  1328. } else {
  1329. datainfo.Code = 0
  1330. datainfo.Item = model
  1331. this.Data["json"] = &datainfo
  1332. this.ServeJSON()
  1333. }
  1334. }
  1335. }
  1336. // @Title 添加
  1337. // @Description 新增
  1338. // @Success 200 {object} controllers.Request
  1339. // @router /add [post]
  1340. func (this *OilSupplierController) AddEntity() {
  1341. var model supplier.OilSupplier
  1342. var modelCert suppliercert.OilSupplierCert
  1343. var modelCertVM suppliercert.OilSupplierVM
  1344. var jsonBlob = this.Ctx.Input.RequestBody
  1345. json.Unmarshal(jsonBlob, &model)
  1346. json.Unmarshal(jsonBlob, &modelCertVM)
  1347. serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1348. var registerUser register.OilCorporateInfo
  1349. sql := " UserName='" + this.User.Username + "'"
  1350. serviceCert.GetEntity(&registerUser, sql)
  1351. canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
  1352. var errinfo ErrorDataInfo
  1353. if !canApply {
  1354. errinfo.Message = "添加失败!供方用户只能申请一次"
  1355. errinfo.Code = -1
  1356. this.Data["json"] = &errinfo
  1357. this.ServeJSON()
  1358. return
  1359. }
  1360. var list []supplier.OilSupplierView
  1361. service := supplier.GetOilSupplierService(utils.DBE)
  1362. service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1363. if len(list) > 0 {
  1364. errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1365. errinfo.Code = -1
  1366. this.Data["json"] = &errinfo
  1367. this.ServeJSON()
  1368. return
  1369. }
  1370. //if model.Id <= 0 {
  1371. // service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1372. // if len(list) > 0 {
  1373. // errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1374. // errinfo.Code = -1
  1375. // this.Data["json"] = &errinfo
  1376. // this.ServeJSON()
  1377. // return
  1378. // }
  1379. //} else {
  1380. // service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1381. // if len(list) > 0 {
  1382. // errinfo.Message = "添加失败! 已存在相关企业的信息,或与其他企业信息重复"
  1383. // errinfo.Code = -1
  1384. // this.Data["json"] = &errinfo
  1385. // this.ServeJSON()
  1386. // return
  1387. // }
  1388. //}
  1389. var session *xorm.Session
  1390. session = utils.DBE.NewSession()
  1391. svc := supplier.GetOilSupplierSession(session)
  1392. svcCert := suppliercert.GetOilSupplierCertSession(session)
  1393. model.CreateOn = time.Now()
  1394. model.CreateBy = this.User.Realname
  1395. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1396. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  1397. defer session.Close()
  1398. err := session.Begin()
  1399. if model.Id <= 0 {
  1400. _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
  1401. } else {
  1402. //判断基本信息是否可修改
  1403. updateCols := svc.GetUpdateCols(OilSupplierCertName, modelCertVM.SupplierTypeCode, model.Id)
  1404. err = svc.UpdateEntityBytbl(OilSupplierName, model.Id, &model, updateCols)
  1405. }
  1406. if err != nil {
  1407. session.Rollback()
  1408. }
  1409. modelCert.SupplierId = model.Id
  1410. modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
  1411. modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
  1412. modelCert.InStyle = modelCertVM.InStyle
  1413. if modelCert.InStyle == suppliercert.PINGSHEN {
  1414. modelCert.IsPay = 0
  1415. } else {
  1416. modelCert.IsPay = 2
  1417. }
  1418. modelCert.Step = 1 //企业信息保存完成
  1419. modelCert.CreateOn = time.Now()
  1420. modelCert.CreateBy = this.User.Realname
  1421. modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1422. _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
  1423. if err != nil {
  1424. session.Rollback()
  1425. }
  1426. // add Commit() after all actions
  1427. err = session.Commit()
  1428. if err == nil {
  1429. //新增
  1430. errinfo.Message = "添加成功!"
  1431. errinfo.Code = 0
  1432. errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
  1433. this.Data["json"] = &errinfo
  1434. this.ServeJSON()
  1435. } else {
  1436. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  1437. errinfo.Code = -1
  1438. this.Data["json"] = &errinfo
  1439. this.ServeJSON()
  1440. }
  1441. }
  1442. // @Title 修改实体
  1443. // @Description 修改实体
  1444. // @Success 200 {object} controllers.Request
  1445. // @router /update/:id/:type/:instyle [post]
  1446. func (this *OilSupplierController) UpdateEntity() {
  1447. id := this.Ctx.Input.Param(":id")
  1448. typeCode := this.Ctx.Input.Param(":type")
  1449. instyle := this.Ctx.Input.Param(":instyle")
  1450. var errinfo ErrorInfo
  1451. if id == "" {
  1452. errinfo.Message = "操作失败!请求信息不完整"
  1453. errinfo.Code = -2
  1454. this.Data["json"] = &errinfo
  1455. this.ServeJSON()
  1456. return
  1457. }
  1458. var model supplier.OilSupplier
  1459. var jsonBlob = this.Ctx.Input.RequestBody
  1460. json.Unmarshal(jsonBlob, &model)
  1461. var list []supplier.OilSupplierView
  1462. service := supplier.GetOilSupplierService(utils.DBE)
  1463. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1464. if len(list) > 0 {
  1465. errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
  1466. errinfo.Code = -1
  1467. this.Data["json"] = &errinfo
  1468. this.ServeJSON()
  1469. return
  1470. }
  1471. svc := supplier.GetOilSupplierService(utils.DBE)
  1472. model.ModifiedOn = time.Now()
  1473. model.ModifiedBy = this.User.Realname
  1474. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1475. //判断基本信息是否可修改
  1476. updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
  1477. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
  1478. isPay := "0"
  1479. if instyle == suppliercert.PINGSHEN {
  1480. isPay = "0"
  1481. } else {
  1482. isPay = "2"
  1483. }
  1484. if err == nil {
  1485. svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle + "', IsPay= " + isPay + " where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'")
  1486. errinfo.Message = "修改成功!"
  1487. errinfo.Code = 0
  1488. this.Data["json"] = &errinfo
  1489. this.ServeJSON()
  1490. } else {
  1491. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  1492. errinfo.Code = -1
  1493. this.Data["json"] = &errinfo
  1494. this.ServeJSON()
  1495. }
  1496. }
  1497. // @Title 修改企业人员情况实体
  1498. // @Description 修改实体
  1499. // @Success 200 {object} controllers.Request
  1500. // @router /updatenumber/:id [post]
  1501. func (this *OilSupplierController) UpdateNumberEntity() {
  1502. idGroup := this.Ctx.Input.Param(":id")
  1503. //id := strings.Split(idGroup, "_")[0]
  1504. certId := strings.Split(idGroup, "_")[1]
  1505. var errinfo ErrorInfo
  1506. if certId == "" {
  1507. errinfo.Message = "操作失败!请求信息不完整"
  1508. errinfo.Code = -2
  1509. this.Data["json"] = &errinfo
  1510. this.ServeJSON()
  1511. return
  1512. }
  1513. var modelCert suppliercert.OilSupplierCert
  1514. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1515. var jsonBlob = this.Ctx.Input.RequestBody
  1516. json.Unmarshal(jsonBlob, &modelCert)
  1517. modelCert.ModifiedOn = time.Now()
  1518. modelCert.ModifiedBy = this.User.Realname
  1519. modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1520. colcerts := []string{
  1521. "Id",
  1522. "InStyle",
  1523. "WorkerTotal",
  1524. "ContractNum ",
  1525. "UniversityNum",
  1526. "TechnicalNum",
  1527. "AboveProfNum",
  1528. "MiddleProfNum",
  1529. "NationalRegNum",
  1530. "NationalCertTotal",
  1531. "DesignerTotal",
  1532. "SkillerTotal",
  1533. "ModifiedOn",
  1534. "ModifiedUserId",
  1535. "ModifiedBy",
  1536. }
  1537. // if modelCert.Step <= 2 {
  1538. // modelCert.Step = 2 //完成企业基本信息
  1539. // colcerts = append(colcerts, "Step")
  1540. // }
  1541. err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
  1542. if err == nil {
  1543. errinfo.Message = "保存成功!"
  1544. errinfo.Code = 0
  1545. this.Data["json"] = &errinfo
  1546. this.ServeJSON()
  1547. } else {
  1548. errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
  1549. errinfo.Code = -1
  1550. this.Data["json"] = &errinfo
  1551. this.ServeJSON()
  1552. }
  1553. }
  1554. // @Title 删除单条信息
  1555. // @Description
  1556. // @Success 200 {object} ErrorInfo
  1557. // @Failure 403 :id 为空
  1558. // @router /delete/:Id [delete]
  1559. func (this *OilSupplierController) DeleteEntity() {
  1560. Id := this.Ctx.Input.Param(":Id")
  1561. var errinfo ErrorInfo
  1562. if Id == "" {
  1563. errinfo.Message = "操作失败!请求信息不完整"
  1564. errinfo.Code = -2
  1565. this.Data["json"] = &errinfo
  1566. this.ServeJSON()
  1567. return
  1568. }
  1569. var model supplier.OilSupplier
  1570. var entityempty supplier.OilSupplier
  1571. svc := supplier.GetOilSupplierService(utils.DBE)
  1572. opdesc := "删除-" + Id
  1573. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  1574. if err == nil {
  1575. errinfo.Message = "删除成功"
  1576. errinfo.Code = 0
  1577. this.Data["json"] = &errinfo
  1578. this.ServeJSON()
  1579. } else {
  1580. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1581. errinfo.Code = -1
  1582. this.Data["json"] = &errinfo
  1583. this.ServeJSON()
  1584. }
  1585. }
  1586. // @Title 删除单条信息
  1587. // @Description
  1588. // @Success 200 {object} ErrorInfo
  1589. // @Failure 403 :id 为空
  1590. // @router /deleteall/:Id/:SupplierTypeCode [delete]
  1591. func (this *OilSupplierController) DeleteAllEntity() {
  1592. Id := this.Ctx.Input.Param(":Id")
  1593. SupplierTypeCode := this.Ctx.Input.Param(":SupplierTypeCode")
  1594. var errinfo ErrorInfo
  1595. if Id == "" {
  1596. errinfo.Message = "操作失败!请求信息不完整"
  1597. errinfo.Code = -2
  1598. this.Data["json"] = &errinfo
  1599. this.ServeJSON()
  1600. return
  1601. }
  1602. svc := supplier.GetOilSupplierService(utils.DBE)
  1603. err := svc.DeleteEntityBytbl(OilSupplierCertName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1604. err = svc.DeleteEntityBytbl(OilSupplierCert2FileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1605. err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
  1606. var model1 suppliercertsub.OilSupplierCert2File
  1607. count1, _ := svc.GetCount(&model1, "SupplierId="+Id)
  1608. if count1 == 0 {
  1609. err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id)
  1610. }
  1611. var model2 suppliercert.OilSupplierCert
  1612. count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
  1613. if count2 == 0 {
  1614. err = svc.DeleteEntityBytbl(OilSupplierName, "Id="+Id)
  1615. }
  1616. if err == nil {
  1617. errinfo.Message = "删除成功"
  1618. errinfo.Code = 0
  1619. this.Data["json"] = &errinfo
  1620. this.ServeJSON()
  1621. } else {
  1622. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  1623. errinfo.Code = -1
  1624. this.Data["json"] = &errinfo
  1625. this.ServeJSON()
  1626. }
  1627. }
  1628. // @Title 判断是否可以申请准入
  1629. // @Description
  1630. // @Success 200 {string} Count
  1631. // @Failure 403 :id 为空
  1632. // @router /iscanapply/:type [get]
  1633. func (this *OilSupplierController) IsCanApply() {
  1634. Type := this.Ctx.Input.Param(":type")
  1635. var errinfo ErrorInfo
  1636. if Type == "" {
  1637. errinfo.Message = "操作失败!请求信息不完整"
  1638. errinfo.Code = -2
  1639. this.Data["json"] = &errinfo
  1640. this.ServeJSON()
  1641. return
  1642. }
  1643. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  1644. var registerUser register.OilCorporateInfo
  1645. sql := " UserName='" + this.User.Username + "'"
  1646. svc.GetEntity(&registerUser, sql)
  1647. canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
  1648. if canApply {
  1649. //判断是否是暂停
  1650. if this.User.IsCompanyUser == 1 {
  1651. var tempMap []map[string]string
  1652. 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 + "'"
  1653. tempMap, _ = svc.DBE.QueryString(sql)
  1654. if tempMap != nil && tempMap[0]["1"] != "" {
  1655. errinfo.Message = "已暂停,不可申请"
  1656. errinfo.Code = -2
  1657. this.Data["json"] = &errinfo
  1658. this.ServeJSON()
  1659. } else {
  1660. errinfo.Message = "无申请记录,可以申请"
  1661. errinfo.Code = 0
  1662. this.Data["json"] = &errinfo
  1663. this.ServeJSON()
  1664. }
  1665. } else {
  1666. errinfo.Message = "无申请记录,可以申请"
  1667. errinfo.Code = 0
  1668. this.Data["json"] = &errinfo
  1669. this.ServeJSON()
  1670. }
  1671. } else {
  1672. errinfo.Message = "供方用户只能申请一次"
  1673. errinfo.Code = -1
  1674. this.Data["json"] = &errinfo
  1675. this.ServeJSON()
  1676. }
  1677. }
  1678. // @Title 判断是否可以修改供方企业信息
  1679. // @Description
  1680. // @Success 200 {string} Count
  1681. // @Failure 403 :id 为空
  1682. // @router /iscanupdatesupplier/:supplierid [get]
  1683. func (this *OilSupplierController) CanUpdateSupplier() {
  1684. supplierId := this.Ctx.Input.Param(":supplierid")
  1685. var errinfo ErrorInfo
  1686. if supplierId == "" {
  1687. errinfo.Message = "操作失败!请求信息不完整"
  1688. errinfo.Code = -2
  1689. this.Data["json"] = &errinfo
  1690. this.ServeJSON()
  1691. return
  1692. }
  1693. Id, _ := strconv.Atoi(supplierId)
  1694. svc := supplier.GetOilSupplierService(utils.DBE)
  1695. canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id)
  1696. if canUpdate {
  1697. errinfo.Message = "可以修改"
  1698. errinfo.Code = 0
  1699. this.Data["json"] = &errinfo
  1700. this.ServeJSON()
  1701. } else {
  1702. errinfo.Message = "此供方已经提交准入申请,不可修改"
  1703. errinfo.Code = -1
  1704. this.Data["json"] = &errinfo
  1705. this.ServeJSON()
  1706. }
  1707. }
  1708. // @Title 获取二级审核人员
  1709. // @Description 获取二级审核人员
  1710. // @router /getauditerbydept/:deptId [get]
  1711. func (this *OilSupplierController) GetAuditerByDept() {
  1712. Id := this.Ctx.Input.Param(":deptId")
  1713. auditstepcode := this.GetString("auditstepcode")
  1714. svc := organize.GetOrganizeService(utils.DBE)
  1715. unitId := svc.GetMyUnitDepartmentId(Id)
  1716. //ids := svc.GetAllChildById(unitId)
  1717. //
  1718. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1719. //var users []userRole.Base_RoleList
  1720. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1721. var userlist []userRole.Base_User
  1722. var setting auditsetting.Base_OilAuditSetting
  1723. usvc := userRole.GetUserService(utils.DBE)
  1724. where := "AuditStepCode='" + auditstepcode + "'"
  1725. svc.GetEntity(&setting, where)
  1726. ids := usvc.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=" + unitId
  1732. svc.GetEntities(&userlist, where)
  1733. }
  1734. var datainfo ErrorDataInfo
  1735. datainfo.Item = userlist
  1736. this.Data["json"] = &datainfo
  1737. this.ServeJSON()
  1738. }
  1739. // @Title 获取二级初审人员
  1740. // @Description 获取二级初审人员
  1741. // @router /getfirauditerbydept/:deptId [get]
  1742. func (this *OilSupplierController) GetFirAuditerByDept() {
  1743. Id := this.Ctx.Input.Param(":deptId")
  1744. auditstepcode := this.GetString("auditstepcode")
  1745. var userlist []userRole.Base_User
  1746. var setting auditsetting.Base_OilAuditSetting
  1747. svc := userRole.GetUserService(utils.DBE)
  1748. where := "AuditStepCode='" + auditstepcode + "'"
  1749. svc.GetEntity(&setting, where)
  1750. svcdepartment := organize.GetOrganizeService(utils.DBE)
  1751. alldep := svcdepartment.GetAllChildById(Id)
  1752. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1753. tempstr := strings.Join(ids, ",")
  1754. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1755. userIds = strings.Trim(userIds, ",")
  1756. if userIds != "" {
  1757. where := "Id in (" + userIds + ")" + "and (UnitId=" + Id + " or Departmentid in (" + alldep + ")) "
  1758. svc.GetEntities(&userlist, where)
  1759. }
  1760. //svc := organize.GetOrganizeService(utils.DBE)
  1761. //
  1762. //ids := svc.GetAllChildById(Id)
  1763. //
  1764. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1765. //var users []userRole.Base_RoleList
  1766. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1767. var datainfo ErrorDataInfo
  1768. datainfo.Item = userlist
  1769. this.Data["json"] = &datainfo
  1770. this.ServeJSON()
  1771. }
  1772. // @Title 获取二级复审人员根据初审人员
  1773. // @Description 获取二级复审人员根据初审人员
  1774. // @router /getauditerbyfirst/:firstId [get]
  1775. func (this *OilSupplierController) GetAuditerByFist() {
  1776. Id := this.Ctx.Input.Param(":firstId")
  1777. auditstepcode := this.GetString("auditstepcode")
  1778. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1779. //orgSrv := organize.GetOrganizeService(utils.DBE)
  1780. var userentity userRole.Base_User
  1781. certSrv.GetEntityById(Id, &userentity)
  1782. var userlist []userRole.Base_User
  1783. var setting auditsetting.Base_OilAuditSetting
  1784. svc := userRole.GetUserService(utils.DBE)
  1785. where := "AuditStepCode='" + auditstepcode + "'"
  1786. svc.GetEntity(&setting, where)
  1787. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1788. tempstr := strings.Join(ids, ",")
  1789. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1790. userIds = strings.Trim(userIds, ",")
  1791. if userIds != "" {
  1792. where := "Id in (" + userIds + ")" + "and UnitId=" + strconv.Itoa(userentity.UnitId)
  1793. svc.GetEntities(&userlist, where)
  1794. }
  1795. //svc := organize.GetOrganizeService(utils.DBE)
  1796. //unitId := svc.GetMyUnitDepartmentId(userentity.Departmentid)
  1797. //ids := svc.GetAllChildById(unitId)
  1798. ////depId := strings.Split(userentity.Superior,",")
  1799. //var users []userRole.Base_RoleList
  1800. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  1801. var datainfo ErrorDataInfo
  1802. datainfo.Item = userlist
  1803. this.Data["json"] = &datainfo
  1804. this.ServeJSON()
  1805. }
  1806. // @Title 获取二级初审人员(不需要验证登录)
  1807. // @Description 获取二级初审人员(不需要验证登录)
  1808. // @router /getauditerbydeptandnologin [get]
  1809. func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
  1810. Id := this.GetString("deptId")
  1811. auditstepcode := this.GetString("auditstepcode")
  1812. var userlist []userRole.Base_User
  1813. var setting auditsetting.Base_OilAuditSetting
  1814. svc := userRole.GetUserService(utils.DBE)
  1815. where := "AuditStepCode='" + auditstepcode + "'"
  1816. svc.GetEntity(&setting, where)
  1817. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  1818. tempstr := strings.Join(ids, ",")
  1819. userIds := strings.Replace(tempstr, "uid_", "", -1)
  1820. userIds = strings.Trim(userIds, ",")
  1821. if userIds != "" {
  1822. where := "Id in (" + userIds + ")" + "and UnitId=" + Id
  1823. svc.GetEntities(&userlist, where)
  1824. }
  1825. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1826. //var users []userRole.Base_RoleList
  1827. //certSrv.GetAuditUser(Id, auditstepcode, &users)
  1828. // certSrv.GetAuditUserByNoLogin(Id, &users)
  1829. var datainfo ErrorDataInfo
  1830. datainfo.Item = userlist
  1831. this.Data["json"] = &datainfo
  1832. this.ServeJSON()
  1833. }
  1834. // @Title
  1835. // @Description
  1836. // @router /getjurisdiction [get]
  1837. func (this *OilSupplierController) GetJurisdiction() {
  1838. svcPerm := permission.GetPermissionService(utils.DBE)
  1839. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_delete")
  1840. var datainfo ErrorDataInfo
  1841. datainfo.Item = isauth
  1842. this.Data["json"] = &datainfo
  1843. this.ServeJSON()
  1844. }
  1845. // @Title 获取列表
  1846. // @Description get user by token
  1847. // @Success 200 {object} []supplier.OilSupplier
  1848. // @router /certlistinterface [get]
  1849. func (this *OilSupplierController) GetEntityListInterface() {
  1850. //获取分页信息
  1851. //page := this.GetPageInfoForm()
  1852. where := " 1=1 "
  1853. //orderby := "Id"
  1854. //asc := false
  1855. //Order := this.GetString("Order")
  1856. //Prop := this.GetString("Prop")
  1857. //if Order != "" && Prop != "" {
  1858. // orderby = Prop
  1859. // if Order == "asc" {
  1860. // asc = true
  1861. // }
  1862. //}
  1863. status := this.GetString("status")
  1864. if status == "1" {
  1865. where += "b.InStyle='1'"
  1866. } else if status == "2" {
  1867. where += "b.InStyle='4'"
  1868. } else if status == "3" {
  1869. where += "b.InStyle='5'"
  1870. } else if status == "4" {
  1871. where += "b.InStyle=''"
  1872. } else if status == "5" {
  1873. where += "b.InStyle=''"
  1874. }
  1875. svc := supplier.GetOilSupplierService(utils.DBE)
  1876. var interfaceData []supplier.InterfaceData
  1877. err := svc.GetInterfaceData(OilSupplierName, OilSupplierFileName, &interfaceData, where)
  1878. var errinfo ErrorDataInfo
  1879. if err == nil {
  1880. errinfo.Message = "成功!"
  1881. errinfo.Code = 0
  1882. errinfo.Item = &interfaceData
  1883. this.Data["json"] = &errinfo
  1884. this.ServeJSON()
  1885. } else {
  1886. errinfo.Message = "失败!"
  1887. errinfo.Code = -1
  1888. this.Data["json"] = &errinfo
  1889. this.ServeJSON()
  1890. }
  1891. }
  1892. // @Title 获取实体
  1893. // @Description 获取实体
  1894. // @Success 200 {object} supplier.OilSupplier
  1895. // @router /getentitybycommercialno/:commercialNo [get]
  1896. func (this *OilSupplierController) GetEntityByCommercialNo() {
  1897. commercialNo := this.Ctx.Input.Param(":commercialNo")
  1898. where := "CommercialNo = '" + commercialNo + "'"
  1899. var model supplier.OilSupplier
  1900. svc := supplier.GetOilSupplierService(utils.DBE)
  1901. svc.GetEntityByWhere(OilSupplierName, where, &model)
  1902. this.Data["json"] = &model
  1903. this.ServeJSON()
  1904. }
  1905. // @Title 更新文件上传
  1906. // @Description 更新文件上传
  1907. // @Param id path string true
  1908. // @Success 200 {object}
  1909. // @router /editsubfile/:id [put]
  1910. func (this *OilSupplierController) EditSubfile() {
  1911. id := this.Ctx.Input.Param(":id")
  1912. var errinfo ErrorInfo
  1913. if id == "" {
  1914. errinfo.Message = "操作失败!请求信息不完整"
  1915. errinfo.Code = -2
  1916. this.Data["json"] = &errinfo
  1917. this.ServeJSON()
  1918. return
  1919. }
  1920. var model supplierscenefile.OilSupplierSceneFile
  1921. var jsonblob = this.Ctx.Input.RequestBody
  1922. json.Unmarshal(jsonblob, &model)
  1923. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  1924. model.FileUrl = strings.Trim(model.FileUrl, "$")
  1925. model.FileName = strings.Trim(model.FileName, "$")
  1926. model.CreateOn = time.Now()
  1927. model.CreateBy = this.User.Realname
  1928. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1929. where := "SupplierId=" + id
  1930. svc.DeleteEntityBytbl(OilSupplierSceneFileName, where)
  1931. _, err := svc.InsertEntity(&model)
  1932. if err == nil {
  1933. errinfo.Message = "操作成功!"
  1934. errinfo.Code = 0
  1935. this.Data["json"] = &errinfo
  1936. this.ServeJSON()
  1937. } else {
  1938. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  1939. errinfo.Code = -1
  1940. this.Data["json"] = &errinfo
  1941. this.ServeJSON()
  1942. }
  1943. }
  1944. // @Title get 导入excel
  1945. // @Description get SampleType by token
  1946. // @Success 200 {object} sampletype.SampleType
  1947. // @router /importexcel [get]
  1948. func (this *OilSupplierController) ImportExcel() {
  1949. url := this.GetString("ExcelUrl")
  1950. var errorinfo ErrorInfo
  1951. if url == "" {
  1952. errorinfo.Code = -2
  1953. errorinfo.Message = "导入失败!"
  1954. this.Data["json"] = &errorinfo
  1955. this.ServeJSON()
  1956. }
  1957. svc := supplier.GetOilSupplierService(utils.DBE)
  1958. log.Printf("url:==" + url) // http://60.30.245.229//upfile/dc1/2,063156edd288
  1959. extranetIP := utils.Cfg.MustValue("server", "extranetIP")
  1960. localIP := utils.Cfg.MustValue("server", "localIP")
  1961. if strings.Index(url, extranetIP) >= 0 {
  1962. url = strings.Replace(url, extranetIP, localIP, 1)
  1963. }
  1964. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  1965. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  1966. utils.DownloadFile(url, filename, _dir)
  1967. t := time.Now()
  1968. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  1969. xlFile, err := xlsx.OpenFile(filePath)
  1970. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  1971. if err != nil {
  1972. fmt.Printf("open failed: %s\n", err)
  1973. }
  1974. var sheet = xlFile.Sheets[0]
  1975. var errLineNum string
  1976. for i := 1; i < len(sheet.Rows); i++ {
  1977. lineNo := strconv.Itoa(i + 1)
  1978. if len(sheet.Rows[i].Cells) != 0 {
  1979. this.OperationCell(svc, lineNo, sheet.Rows[i].Cells, &errLineNum)
  1980. }
  1981. }
  1982. os.Remove(filePath)
  1983. if errLineNum != "" {
  1984. errorinfo.Code = -1
  1985. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  1986. this.Data["json"] = &errorinfo
  1987. this.ServeJSON()
  1988. } else {
  1989. elapsed := time.Since(t)
  1990. log.Println(elapsed)
  1991. errorinfo.Code = 0
  1992. errorinfo.Message = "导入成功!"
  1993. this.Data["json"] = &errorinfo
  1994. this.ServeJSON()
  1995. }
  1996. }
  1997. func (this *OilSupplierController) OperationCell(svc *supplier.OilSupplierService, lineNo string, cellsArr []*xlsx.Cell, errLineNum *string) {
  1998. defer func() {
  1999. if err := recover(); err != nil {
  2000. log.Println("err"+lineNo, err)
  2001. *errLineNum += lineNo + ","
  2002. }
  2003. }()
  2004. cells := cellsArr
  2005. supplierName := strings.TrimSpace(cells[0].Value)
  2006. oilCertificateNo := ""
  2007. if len(cells) >= 2 {
  2008. oilCertificateNo = strings.TrimSpace(cells[1].Value)
  2009. }
  2010. cols := []string{"PACNumber"}
  2011. var entity supplier.OilSupplier
  2012. entity.PACNumber = oilCertificateNo
  2013. where := "SupplierName='" + supplierName + "'"
  2014. err := svc.UpdateEntityBywheretbl(OilSupplierName, &entity, cols, where)
  2015. if err != nil {
  2016. panic(err)
  2017. }
  2018. }
  2019. // @Title 获取列表
  2020. // @Description get user by token
  2021. // @Success 200 {object} []supplier.OilSupplier
  2022. // @router /getscenefilelist [get]
  2023. func (this *OilSupplierController) GetSceneFileList() {
  2024. supplierId := this.GetString("SupplierId")
  2025. var model supplierscenefile.OilSupplierSceneFile
  2026. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  2027. where := "SupplierId=" + supplierId
  2028. svc.GetEntity(&model, where)
  2029. var errinfo ErrorDataInfo
  2030. errinfo.Item = model
  2031. errinfo.Code = 1
  2032. this.Data["json"] = &errinfo
  2033. this.ServeJSON()
  2034. }