supplier.go 80 KB

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