supplier.go 74 KB

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