supplier.go 126 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  4. BlackList "dashoo.cn/backend/api/business/oilsupplier/blacklist"
  5. "dashoo.cn/backend/api/business/oilsupplier/qualchange"
  6. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
  7. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  8. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  9. "dashoo.cn/backend/api/business/oilsupplier/supplierscenefile"
  10. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  11. "dashoo.cn/backend/api/business/register"
  12. "dashoo.cn/business3/parameter"
  13. "encoding/json"
  14. "fmt"
  15. . "github.com/linxGnu/goseaweedfs"
  16. "github.com/tealeg/xlsx"
  17. "log"
  18. "os"
  19. "strconv"
  20. "strings"
  21. "time"
  22. "dashoo.cn/backend/api/business/auditsetting"
  23. "dashoo.cn/backend/api/business/organize"
  24. "dashoo.cn/business2/permission"
  25. "dashoo.cn/backend/api/business/workflow"
  26. "dashoo.cn/business2/areajson"
  27. "dashoo.cn/business2/items"
  28. "dashoo.cn/backend/api/business/baseUser"
  29. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  30. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  31. . "dashoo.cn/backend/api/controllers"
  32. "dashoo.cn/business2/userRole"
  33. "dashoo.cn/utils"
  34. "github.com/go-xorm/xorm"
  35. )
  36. type OilSupplierController struct {
  37. BaseController
  38. }
  39. // @Title 获取列表
  40. // @Description get user by token
  41. // @Success 200 {object} []supplier.OilSupplier
  42. // @router /list [get]
  43. func (this *OilSupplierController) GetEntityList() {
  44. //获取分页信息
  45. page := this.GetPageInfoForm()
  46. where := " 1=1 "
  47. orderby := "Id"
  48. asc := false
  49. Order := this.GetString("Order")
  50. Prop := this.GetString("Prop")
  51. if Order != "" && Prop != "" {
  52. orderby = Prop
  53. if Order == "asc" {
  54. asc = true
  55. }
  56. }
  57. Id := this.GetString("Id")
  58. SupplierName := this.GetString("SupplierName")
  59. OilCertificateNo := this.GetString("OilCertificateNo")
  60. Grade := this.GetString("Grade")
  61. MgrUnit := this.GetString("MgrUnit")
  62. OperType := this.GetString("OperType")
  63. Country := this.GetString("Country")
  64. MaunAgent := this.GetString("MaunAgent")
  65. ConstructTeam := this.GetString("ConstructTeam")
  66. CommercialNo := this.GetString("CommercialNo")
  67. OrganCode := this.GetString("OrganCode")
  68. CountryTaxNo := this.GetString("CountryTaxNo")
  69. LocalTaxNo := this.GetString("LocalTaxNo")
  70. Address := this.GetString("Address")
  71. Province := this.GetString("Province")
  72. City := this.GetString("City")
  73. Street := this.GetString("Street")
  74. HouseNo := this.GetString("HouseNo")
  75. ZipCode := this.GetString("ZipCode")
  76. QualitySystemCert := this.GetString("QualitySystemCert")
  77. ProductQualityCert := this.GetString("ProductQualityCert")
  78. MaunLicense := this.GetString("MaunLicense")
  79. QualifCert := this.GetString("QualifCert")
  80. QualifCertLevel := this.GetString("QualifCertLevel")
  81. SafetyLicense := this.GetString("SafetyLicense")
  82. TechServiceLic := this.GetString("TechServiceLic")
  83. TJInNotify := this.GetString("TJInNotify")
  84. SpecIndustryCert := this.GetString("SpecIndustryCert")
  85. LegalPerson := this.GetString("LegalPerson")
  86. CategoryCode := this.GetString("CategoryCode")
  87. CategoryName := this.GetString("CategoryName")
  88. RegCapital := this.GetString("RegCapital")
  89. Currency := this.GetString("Currency")
  90. ContactName := this.GetString("ContactName")
  91. CompanyType := this.GetString("CompanyType")
  92. SetupTime := this.GetString("SetupTime")
  93. DepositBank := this.GetString("DepositBank")
  94. BankAccount := this.GetString("BankAccount")
  95. EMail := this.GetString("EMail")
  96. BankCreditRating := this.GetString("BankCreditRating")
  97. Mobile := this.GetString("Mobile")
  98. Telphone := this.GetString("Telphone")
  99. Fax := this.GetString("Fax")
  100. CompanyTel := this.GetString("CompanyTel")
  101. QQ := this.GetString("QQ")
  102. CompanyUrl := this.GetString("CompanyUrl")
  103. SpecSupplier := this.GetString("SpecSupplier")
  104. SpecTypeCode := this.GetString("SpecTypeCode")
  105. SpecTypeName := this.GetString("SpecTypeName")
  106. Remark := this.GetString("Remark")
  107. IsDelete := this.GetString("IsDelete")
  108. CreateOn := this.GetString("CreateOn")
  109. CreateUserId := this.GetString("CreateUserId")
  110. CreateBy := this.GetString("CreateBy")
  111. ModifiedOn := this.GetString("ModifiedOn")
  112. ModifiedUserId := this.GetString("ModifiedUserId")
  113. ModifiedBy := this.GetString("ModifiedBy")
  114. if Id != "" {
  115. where = where + " and Id like '%" + Id + "%'"
  116. }
  117. if SupplierName != "" {
  118. where = where + " and SupplierName like '%" + SupplierName + "%'"
  119. }
  120. if OilCertificateNo != "" {
  121. where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
  122. }
  123. if Grade != "" {
  124. where = where + " and Grade like '%" + Grade + "%'"
  125. }
  126. if MgrUnit != "" {
  127. where = where + " and MgrUnit like '%" + MgrUnit + "%'"
  128. }
  129. if OperType != "" {
  130. where = where + " and OperType like '%" + OperType + "%'"
  131. }
  132. if Country != "" {
  133. where = where + " and Country like '%" + Country + "%'"
  134. }
  135. if MaunAgent != "" {
  136. where = where + " and MaunAgent like '%" + MaunAgent + "%'"
  137. }
  138. if ConstructTeam != "" {
  139. where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
  140. }
  141. if CommercialNo != "" {
  142. where = where + " and CommercialNo like '%" + CommercialNo + "%'"
  143. }
  144. if OrganCode != "" {
  145. where = where + " and OrganCode like '%" + OrganCode + "%'"
  146. }
  147. if CountryTaxNo != "" {
  148. where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
  149. }
  150. if LocalTaxNo != "" {
  151. where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
  152. }
  153. if Address != "" {
  154. where = where + " and Address like '%" + Address + "%'"
  155. }
  156. if Province != "" {
  157. where = where + " and Province like '%" + Province + "%'"
  158. }
  159. if City != "" {
  160. where = where + " and City like '%" + City + "%'"
  161. }
  162. if Street != "" {
  163. where = where + " and Street like '%" + Street + "%'"
  164. }
  165. if HouseNo != "" {
  166. where = where + " and HouseNo like '%" + HouseNo + "%'"
  167. }
  168. if ZipCode != "" {
  169. where = where + " and ZipCode like '%" + ZipCode + "%'"
  170. }
  171. if QualitySystemCert != "" {
  172. where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
  173. }
  174. if ProductQualityCert != "" {
  175. where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
  176. }
  177. if MaunLicense != "" {
  178. where = where + " and MaunLicense like '%" + MaunLicense + "%'"
  179. }
  180. if QualifCert != "" {
  181. where = where + " and QualifCert like '%" + QualifCert + "%'"
  182. }
  183. if QualifCertLevel != "" {
  184. where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
  185. }
  186. if SafetyLicense != "" {
  187. where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
  188. }
  189. if TechServiceLic != "" {
  190. where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
  191. }
  192. if TJInNotify != "" {
  193. where = where + " and TJInNotify like '%" + TJInNotify + "%'"
  194. }
  195. if SpecIndustryCert != "" {
  196. where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  197. }
  198. if LegalPerson != "" {
  199. where = where + " and LegalPerson like '%" + LegalPerson + "%'"
  200. }
  201. if CategoryCode != "" {
  202. where = where + " and CategoryCode like '%" + CategoryCode + "%'"
  203. }
  204. if CategoryName != "" {
  205. where = where + " and CategoryName like '%" + CategoryName + "%'"
  206. }
  207. if RegCapital != "" {
  208. where = where + " and RegCapital like '%" + RegCapital + "%'"
  209. }
  210. if Currency != "" {
  211. where = where + " and Currency like '%" + Currency + "%'"
  212. }
  213. if ContactName != "" {
  214. where = where + " and ContactName like '%" + ContactName + "%'"
  215. }
  216. if CompanyType != "" {
  217. where = where + " and CompanyType like '%" + CompanyType + "%'"
  218. }
  219. if SetupTime != "" {
  220. where = where + " and SetupTime like '%" + SetupTime + "%'"
  221. }
  222. if DepositBank != "" {
  223. where = where + " and DepositBank like '%" + DepositBank + "%'"
  224. }
  225. if BankAccount != "" {
  226. where = where + " and BankAccount like '%" + BankAccount + "%'"
  227. }
  228. if EMail != "" {
  229. where = where + " and EMail like '%" + EMail + "%'"
  230. }
  231. if BankCreditRating != "" {
  232. where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
  233. }
  234. if Mobile != "" {
  235. where = where + " and Mobile like '%" + Mobile + "%'"
  236. }
  237. if Telphone != "" {
  238. where = where + " and Telphone like '%" + Telphone + "%'"
  239. }
  240. if Fax != "" {
  241. where = where + " and Fax like '%" + Fax + "%'"
  242. }
  243. if CompanyTel != "" {
  244. where = where + " and CompanyTel like '%" + CompanyTel + "%'"
  245. }
  246. if QQ != "" {
  247. where = where + " and QQ like '%" + QQ + "%'"
  248. }
  249. if CompanyUrl != "" {
  250. where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
  251. }
  252. if SpecSupplier != "" {
  253. where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
  254. }
  255. if SpecTypeCode != "" {
  256. where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
  257. }
  258. if SpecTypeName != "" {
  259. where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
  260. }
  261. if Remark != "" {
  262. where = where + " and Remark like '%" + Remark + "%'"
  263. }
  264. if IsDelete != "" {
  265. where = where + " and IsDelete like '%" + IsDelete + "%'"
  266. }
  267. if CreateUserId != "" {
  268. where = where + " and CreateUserId like '%" + CreateUserId + "%'"
  269. }
  270. if CreateBy != "" {
  271. where = where + " and CreateBy like '%" + CreateBy + "%'"
  272. }
  273. if ModifiedOn != "" {
  274. where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
  275. }
  276. if ModifiedUserId != "" {
  277. where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
  278. }
  279. if ModifiedBy != "" {
  280. where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
  281. }
  282. if CreateOn != "" {
  283. dates := strings.Split(CreateOn, ",")
  284. if len(dates) == 2 {
  285. minDate := dates[0]
  286. maxDate := dates[1]
  287. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  288. }
  289. }
  290. //企业用户必须加创建人条件
  291. if this.User.IsCompanyUser == 1 {
  292. where = where + " and CreateUserId = '" + this.User.Id + "'"
  293. } else {
  294. //超级管理员和有查看所有数据权限的用户不加条件
  295. svcPerm := permission.GetPermissionService(utils.DBE)
  296. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  297. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  298. where = where + " and CreateUserId = '" + this.User.Id + "'"
  299. }
  300. }
  301. svc := supplier.GetOilSupplierService(utils.DBE)
  302. var list []supplier.OilSupplier
  303. total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  304. var datainfo DataInfo
  305. datainfo.Items = list
  306. datainfo.CurrentItemCount = total
  307. datainfo.PageIndex = page.CurrentPage
  308. datainfo.ItemsPerPage = page.Size
  309. this.Data["json"] = &datainfo
  310. this.ServeJSON()
  311. }
  312. // @Title 获取列表
  313. // @Description get user by token
  314. // @Success 200 {object} []supplier.OilSupplier
  315. // @router /certlist [get]
  316. func (this *OilSupplierController) GetJoinCertEntityList() {
  317. //获取分页信息
  318. page := this.GetPageInfoForm()
  319. where := " 1=1 "
  320. orderby := "Id"
  321. asc := false
  322. Order := this.GetString("Order")
  323. Prop := this.GetString("Prop")
  324. if Order != "" && Prop != "" {
  325. orderby = Prop
  326. if Order == "asc" {
  327. asc = true
  328. }
  329. }
  330. SupplierName := this.GetString("SupplierName")
  331. SupplierTypeName := this.GetString("SupplierTypeName")
  332. CreateOn := this.GetString("CreateOn")
  333. SupplierTypeCode := this.GetString("SupplierTypeCode")
  334. OperType := this.GetString("OperType")
  335. SpecTypeCode := this.GetString("SpecTypeCode")
  336. Country := this.GetString("Country")
  337. InStyle := this.GetString("InStyle")
  338. MgrUnit := this.GetString("MgrUnit")
  339. PACNumber := this.GetString("PACNumber")
  340. CommercialNo := this.GetString("CommercialNo")
  341. Province := this.GetString("Province")
  342. City := this.GetString("City")
  343. Street := this.GetString("Street")
  344. Address := this.GetString("Address")
  345. LinkProvince := this.GetString("LinkProvince")
  346. LinkCity := this.GetString("LinkCity")
  347. LinkStreet := this.GetString("LinkStreet")
  348. LinkAddress := this.GetString("LinkAddress")
  349. LegalPerson := this.GetString("LegalPerson")
  350. ContactName := this.GetString("ContactName")
  351. CompanyType := this.GetString("CompanyType")
  352. SetupTime := this.GetString("SetupTime")
  353. RegCapital1 := this.GetString("RegCapital1")
  354. RegCapital2 := this.GetString("RegCapital2")
  355. BusinessScope := this.GetString("BusinessScope")
  356. //where = where + " and b.InFlag != '4'"
  357. if SupplierName != "" {
  358. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  359. }
  360. if SupplierTypeName != "" {
  361. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  362. }
  363. if CreateOn != "" {
  364. dates := strings.Split(CreateOn, ",")
  365. if len(dates) == 2 {
  366. minDate := dates[0]
  367. maxDate := dates[1]
  368. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  369. }
  370. }
  371. if SupplierTypeCode != "" {
  372. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  373. }
  374. if OperType != "" {
  375. where = where + " and a.OperType like '%" + OperType + "%'"
  376. }
  377. if SpecTypeCode != "" {
  378. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  379. }
  380. if Country != "" {
  381. where = where + " and a.Country like '%" + Country + "%'"
  382. }
  383. if InStyle != "" {
  384. where = where + " and b.InStyle ='" + InStyle + "'"
  385. }
  386. if MgrUnit != "" {
  387. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  388. }
  389. if PACNumber != "" {
  390. where = where + " and a.PACNumber ='" + PACNumber + "'"
  391. }
  392. if CommercialNo != "" {
  393. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  394. }
  395. if Province != "" {
  396. where = where + " and a.Province ='" + Province + "'"
  397. }
  398. if City != "" {
  399. where = where + " and a.City ='" + City + "'"
  400. }
  401. if Street != "" {
  402. where = where + " and a.Street ='" + Street + "'"
  403. }
  404. if Address != "" {
  405. where = where + " and a.Address ='" + Address + "'"
  406. }
  407. if LinkProvince != "" {
  408. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  409. }
  410. if LinkCity != "" {
  411. where = where + " and a.LinkCity ='" + LinkCity + "'"
  412. }
  413. if LinkStreet != "" {
  414. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  415. }
  416. if LinkAddress != "" {
  417. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  418. }
  419. if LegalPerson != "" {
  420. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  421. }
  422. if ContactName != "" {
  423. where = where + " and a.ContactName ='" + ContactName + "'"
  424. }
  425. if CompanyType != "" {
  426. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  427. }
  428. if SetupTime != "" {
  429. where = where + " and a.SetupTime ='" + SetupTime + "'"
  430. }
  431. //注册资金范围
  432. if RegCapital1 != "" {
  433. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  434. }
  435. if RegCapital2 != "" {
  436. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  437. }
  438. if BusinessScope != "" {
  439. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  440. }
  441. //企业用户只看自己的数据记录
  442. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  443. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  444. if extOrganizeId == this.User.DepartmentId {
  445. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  446. }*/
  447. svc := supplier.GetOilSupplierService(utils.DBE)
  448. var registerUser register.OilCorporateInfo
  449. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  450. svc.GetEntity(&registerUser, sql)
  451. //企业用户必须加创建人条件
  452. if this.User.IsCompanyUser == 1 {
  453. where = where + " and (a.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  454. } else {
  455. //超级管理员和有查看所有数据权限的用户不加条件
  456. svcPerm := permission.GetPermissionService(utils.DBE)
  457. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  458. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  459. where = where + " and b.CreateUserId = '" + this.User.Id + "'"
  460. }
  461. }
  462. var list []supplier.OilSupplierView
  463. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  464. var datainfo DataInfo
  465. datainfo.Items = list
  466. datainfo.CurrentItemCount = total
  467. datainfo.PageIndex = page.CurrentPage
  468. datainfo.ItemsPerPage = page.Size
  469. this.Data["json"] = &datainfo
  470. this.ServeJSON()
  471. }
  472. // @Title 获取集中评审列表
  473. // @Description get user by token
  474. // @Success 200 {object} []supplier.OilSupplier
  475. // @router /jzps_certlist [get]
  476. func (this *OilSupplierController) GetJZPSJoinCertEntityList() {
  477. //获取分页信息
  478. page := this.GetPageInfoForm()
  479. where := " 1=1 "
  480. orderby := "Id"
  481. asc := false
  482. Order := this.GetString("Order")
  483. Prop := this.GetString("Prop")
  484. if Order != "" && Prop != "" {
  485. orderby = Prop
  486. if Order == "asc" {
  487. asc = true
  488. }
  489. }
  490. SupplierName := this.GetString("SupplierName")
  491. SupplierTypeName := this.GetString("SupplierTypeName")
  492. CreateOn := this.GetString("CreateOn")
  493. SupplierTypeCode := this.GetString("SupplierTypeCode")
  494. OperType := this.GetString("OperType")
  495. SpecTypeCode := this.GetString("SpecTypeCode")
  496. Country := this.GetString("Country")
  497. InStyle := this.GetString("InStyle")
  498. MgrUnit := this.GetString("MgrUnit")
  499. PACNumber := this.GetString("PACNumber")
  500. CommercialNo := this.GetString("CommercialNo")
  501. Province := this.GetString("Province")
  502. City := this.GetString("City")
  503. Street := this.GetString("Street")
  504. Address := this.GetString("Address")
  505. LinkProvince := this.GetString("LinkProvince")
  506. LinkCity := this.GetString("LinkCity")
  507. LinkStreet := this.GetString("LinkStreet")
  508. LinkAddress := this.GetString("LinkAddress")
  509. LegalPerson := this.GetString("LegalPerson")
  510. ContactName := this.GetString("ContactName")
  511. CompanyType := this.GetString("CompanyType")
  512. SetupTime := this.GetString("SetupTime")
  513. RegCapital1 := this.GetString("RegCapital1")
  514. RegCapital2 := this.GetString("RegCapital2")
  515. BusinessScope := this.GetString("BusinessScope")
  516. RecUnitName := this.GetString("RecUnitName")
  517. RecUnitId := this.GetString("RecUnitId")
  518. ThirdAudit := this.GetString("ThirdAudit")
  519. if SupplierName != "" {
  520. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  521. }
  522. if SupplierTypeName != "" {
  523. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  524. }
  525. if CreateOn != "" {
  526. dates := strings.Split(CreateOn, ",")
  527. if len(dates) == 2 {
  528. minDate := dates[0]
  529. maxDate := dates[1]
  530. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  531. }
  532. }
  533. if SupplierTypeCode != "" {
  534. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  535. }
  536. if OperType != "" {
  537. where = where + " and a.OperType like '%" + OperType + "%'"
  538. }
  539. if SpecTypeCode != "" {
  540. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  541. }
  542. if Country != "" {
  543. where = where + " and a.Country like '%" + Country + "%'"
  544. }
  545. if InStyle != "" {
  546. where = where + " and b.InStyle ='" + InStyle + "'"
  547. }
  548. if MgrUnit != "" {
  549. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  550. }
  551. if PACNumber != "" {
  552. where = where + " and a.PACNumber ='" + PACNumber + "'"
  553. }
  554. if CommercialNo != "" {
  555. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  556. }
  557. if Province != "" {
  558. where = where + " and a.Province ='" + Province + "'"
  559. }
  560. if City != "" {
  561. where = where + " and a.City ='" + City + "'"
  562. }
  563. if Street != "" {
  564. where = where + " and a.Street ='" + Street + "'"
  565. }
  566. if Address != "" {
  567. where = where + " and a.Address ='" + Address + "'"
  568. }
  569. if LinkProvince != "" {
  570. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  571. }
  572. if LinkCity != "" {
  573. where = where + " and a.LinkCity ='" + LinkCity + "'"
  574. }
  575. if LinkStreet != "" {
  576. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  577. }
  578. if LinkAddress != "" {
  579. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  580. }
  581. if LegalPerson != "" {
  582. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  583. }
  584. if ContactName != "" {
  585. where = where + " and a.ContactName ='" + ContactName + "'"
  586. }
  587. if CompanyType != "" {
  588. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  589. }
  590. if SetupTime != "" {
  591. where = where + " and a.SetupTime ='" + SetupTime + "'"
  592. }
  593. //注册资金范围
  594. if RegCapital1 != "" {
  595. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  596. }
  597. if RegCapital2 != "" {
  598. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  599. }
  600. if BusinessScope != "" {
  601. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  602. }
  603. if RecUnitName != "" {
  604. where = where + " and b.RecUnitName like '%" + RecUnitName + "%'"
  605. }
  606. if RecUnitId != "" {
  607. where = where + " and b.RecUnitId = '" + RecUnitId + "' "
  608. }
  609. if ThirdAudit != "" {
  610. where = where + " and b.ThirdAudit = '" + ThirdAudit + "' "
  611. }
  612. status := this.GetString("Status")
  613. if status != "" {
  614. where = where + " and b.Status='" + status + "'"
  615. }
  616. //企业用户必须加创建人条件
  617. if this.User.IsCompanyUser == 1 {
  618. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  619. } else {
  620. //超级管理员和有查看所有数据权限的用户不加条件
  621. svcPerm := permission.GetPermissionService(utils.DBE)
  622. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  623. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  624. //根据工作流查找
  625. //集中评审相关人可看数据
  626. actisvc := workflow.GetActivitiService(utils.DBE)
  627. //找出待办任务===准入
  628. var certIdList string
  629. ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  630. if len(strings.Trim(ids, ",")) > 0 {
  631. certIdList += strings.Trim(ids, ",") + ","
  632. }
  633. certIdList = strings.Trim(certIdList, ",")
  634. certIdarr := strings.Split(certIdList, ",")
  635. for i, item := range certIdarr {
  636. idx := strings.Index(item, "-")
  637. if idx >= 0 {
  638. certIdarr[i] = strings.Split(item, "-")[0]
  639. }
  640. }
  641. certIdList = strings.Join(certIdarr, ",")
  642. if certIdList != "" {
  643. where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
  644. } else {
  645. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  646. }
  647. }
  648. }
  649. svc := supplier.GetOilSupplierService(utils.DBE)
  650. var list []supplier.OilSupplierView1
  651. //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  652. total := svc.GetMyPagingEntitiesWithOrderBytbl3(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  653. var datainfo DataInfo
  654. datainfo.Items = list
  655. datainfo.CurrentItemCount = total
  656. datainfo.PageIndex = page.CurrentPage
  657. datainfo.ItemsPerPage = page.Size
  658. this.Data["json"] = &datainfo
  659. this.ServeJSON()
  660. }
  661. // @Title 集中评审列表导出
  662. // @Description get user by token
  663. // @Success 200 {object} []supplier.OilSupplier
  664. // @router /jzpsListExport [get]
  665. func (this *OilSupplierController) JzpsListExport() {
  666. where := " 1=1 "
  667. SupplierName := this.GetString("SupplierName")
  668. SupplierTypeName := this.GetString("SupplierTypeName")
  669. CreateOn := this.GetString("CreateOn")
  670. SupplierTypeCode := this.GetString("SupplierTypeCode")
  671. OperType := this.GetString("OperType")
  672. SpecTypeCode := this.GetString("SpecTypeCode")
  673. Country := this.GetString("Country")
  674. InStyle := this.GetString("InStyle")
  675. MgrUnit := this.GetString("MgrUnit")
  676. PACNumber := this.GetString("PACNumber")
  677. CommercialNo := this.GetString("CommercialNo")
  678. Province := this.GetString("Province")
  679. City := this.GetString("City")
  680. Street := this.GetString("Street")
  681. Address := this.GetString("Address")
  682. LinkProvince := this.GetString("LinkProvince")
  683. LinkCity := this.GetString("LinkCity")
  684. LinkStreet := this.GetString("LinkStreet")
  685. LinkAddress := this.GetString("LinkAddress")
  686. LegalPerson := this.GetString("LegalPerson")
  687. ContactName := this.GetString("ContactName")
  688. CompanyType := this.GetString("CompanyType")
  689. SetupTime := this.GetString("SetupTime")
  690. RegCapital1 := this.GetString("RegCapital1")
  691. RegCapital2 := this.GetString("RegCapital2")
  692. BusinessScope := this.GetString("BusinessScope")
  693. RecUnitName := this.GetString("RecUnitName")
  694. RecUnitId := this.GetString("RecUnitId")
  695. ThirdAudit := this.GetString("ThirdAudit")
  696. if SupplierName != "" {
  697. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  698. }
  699. if CreateOn != "" {
  700. dates := strings.Split(CreateOn, ",")
  701. if len(dates) == 2 {
  702. minDate := dates[0]
  703. maxDate := dates[1]
  704. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  705. }
  706. }
  707. if SupplierTypeCode != "" {
  708. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  709. }
  710. if OperType != "" {
  711. where = where + " and a.OperType like '%" + OperType + "%'"
  712. }
  713. if SpecTypeCode != "" {
  714. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  715. }
  716. if Country != "" {
  717. where = where + " and a.Country like '%" + Country + "%'"
  718. }
  719. if InStyle != "" {
  720. where = where + " and b.InStyle ='" + InStyle + "'"
  721. }
  722. if MgrUnit != "" {
  723. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  724. }
  725. if PACNumber != "" {
  726. where = where + " and a.PACNumber ='" + PACNumber + "'"
  727. }
  728. if CommercialNo != "" {
  729. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  730. }
  731. if Province != "" {
  732. where = where + " and a.Province ='" + Province + "'"
  733. }
  734. if City != "" {
  735. where = where + " and a.City ='" + City + "'"
  736. }
  737. if Street != "" {
  738. where = where + " and a.Street ='" + Street + "'"
  739. }
  740. if Address != "" {
  741. where = where + " and a.Address ='" + Address + "'"
  742. }
  743. if LinkProvince != "" {
  744. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  745. }
  746. if LinkCity != "" {
  747. where = where + " and a.LinkCity ='" + LinkCity + "'"
  748. }
  749. if LinkStreet != "" {
  750. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  751. }
  752. if LinkAddress != "" {
  753. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  754. }
  755. if LegalPerson != "" {
  756. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  757. }
  758. if ContactName != "" {
  759. where = where + " and a.ContactName ='" + ContactName + "'"
  760. }
  761. if CompanyType != "" {
  762. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  763. }
  764. if SetupTime != "" {
  765. where = where + " and a.SetupTime ='" + SetupTime + "'"
  766. }
  767. //注册资金范围
  768. if RegCapital1 != "" {
  769. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  770. }
  771. if RegCapital2 != "" {
  772. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  773. }
  774. if BusinessScope != "" {
  775. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  776. }
  777. if RecUnitName != "" {
  778. where = where + " and b.RecUnitName like '%" + RecUnitName + "%'"
  779. }
  780. if RecUnitId != "" {
  781. where = where + " and b.RecUnitId = '" + RecUnitId + "' "
  782. }
  783. if ThirdAudit != "" {
  784. where = where + " and b.ThirdAudit = '" + ThirdAudit + "' "
  785. }
  786. status := this.GetString("Status")
  787. if status != "" {
  788. where = where + " and b.Status='" + status + "'"
  789. }
  790. //企业用户必须加创建人条件
  791. if this.User.IsCompanyUser == 1 {
  792. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  793. } else {
  794. //超级管理员和有查看所有数据权限的用户不加条件
  795. svcPerm := permission.GetPermissionService(utils.DBE)
  796. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  797. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  798. //根据工作流查找
  799. //集中评审相关人可看数据
  800. actisvc := workflow.GetActivitiService(utils.DBE)
  801. //找出待办任务===准入
  802. var certIdList string
  803. ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  804. if len(strings.Trim(ids, ",")) > 0 {
  805. certIdList += strings.Trim(ids, ",") + ","
  806. }
  807. certIdList = strings.Trim(certIdList, ",")
  808. certIdarr := strings.Split(certIdList, ",")
  809. for i, item := range certIdarr {
  810. idx := strings.Index(item, "-")
  811. if idx >= 0 {
  812. certIdarr[i] = strings.Split(item, "-")[0]
  813. }
  814. }
  815. certIdList = strings.Join(certIdarr, ",")
  816. if certIdList != "" {
  817. where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
  818. } else {
  819. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  820. }
  821. }
  822. }
  823. where1 := where
  824. svc := supplier.GetOilSupplierService(utils.DBE)
  825. var list []supplier.OilSupplierExport
  826. var list1 []supplier.OilSupplierExport
  827. if SupplierTypeName == "物资类" {
  828. svc.GetMyPagingEntitiesWithOrderBytblExportNew(OilSupplierName, OilSupplierCertName, &list1, where1)
  829. } else if SupplierTypeName == "服务类" || SupplierTypeName == "基建类"{
  830. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  831. svc.GetMyPagingEntitiesWithOrderBytblExport(OilSupplierName, OilSupplierCertName, &list, where)
  832. } else {
  833. where = where + " and (b.SupplierTypeCode = '02' or b.SupplierTypeCode = '03')"
  834. svc.GetMyPagingEntitiesWithOrderBytblExport(OilSupplierName, OilSupplierCertName, &list, where)
  835. svc.GetMyPagingEntitiesWithOrderBytblExportNew(OilSupplierName, OilSupplierCertName, &list1, where1)
  836. }
  837. fileTitle := "集中评审"
  838. showColumnArr := "序号,审核状态,企业名称,准入类别,审核处室,推荐单位,法人,工商注册号,注册资本,币种,公司类型,成立时间,手机号,二位准入范围,八位准入范围"
  839. f := xlsx.NewFile()
  840. sheet, _ := f.AddSheet(fileTitle)
  841. cellName := strings.Split(showColumnArr, ",")
  842. row := sheet.AddRow()
  843. row.WriteSlice(&cellName, -1)
  844. for idx, item := range list {
  845. var certSubList []suppliercertsub.OilSupplierCertSub
  846. svc.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = "+strconv.Itoa(item.CertId), &certSubList)
  847. subName := ""
  848. for _, certSub := range certSubList {
  849. subName += "," + certSub.Code + ":" + certSub.Name
  850. }
  851. regCapital := strconv.FormatFloat(item.RegCapital, 'f', 2, 64)
  852. currency := "人民币"
  853. if item.Currency == "人民币元" {
  854. currency = "人民币"
  855. }
  856. if item.Currency == "JPY" {
  857. currency = "日元"
  858. }
  859. if item.Currency == "USD" {
  860. currency = "美元"
  861. }
  862. if item.Currency == "EUR" {
  863. currency = "欧元"
  864. }
  865. dataString := strconv.Itoa(idx+1) + "+待集中评审+" + item.SupplierName + "+" + item.SupplierTypeName + "+" + item.FullName + "+" + item.RecUnitName + "+" + item.LegalPerson + "+" + item.CommercialNo + "+" +
  866. regCapital + "+" + currency + "+" + item.CompanyType + "+" + utils.ToStr(item.SetupTime.Format("2006-01-02")) + "+" + item.Mobile + "+" + item.SubName + "+" + strings.TrimLeft(subName, ",")
  867. cellName := strings.Split(dataString, "+")
  868. row := sheet.AddRow()
  869. row.WriteSlice(&cellName, -1)
  870. }
  871. for idx, item := range list1 {
  872. var certSubList []suppliercertsub.OilSupplierCertSub
  873. svc.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = "+strconv.Itoa(item.CertId), &certSubList)
  874. subName := ""
  875. for _, certSub := range certSubList {
  876. subName += "," + certSub.Code + ":" + certSub.Name
  877. }
  878. regCapital := strconv.FormatFloat(item.RegCapital, 'f', 2, 64)
  879. currency := "人民币"
  880. if item.Currency == "人民币元" {
  881. currency = "人民币"
  882. }
  883. if item.Currency == "JPY" {
  884. currency = "日元"
  885. }
  886. if item.Currency == "USD" {
  887. currency = "美元"
  888. }
  889. if item.Currency == "EUR" {
  890. currency = "欧元"
  891. }
  892. dataString := strconv.Itoa(idx+1) + "+待集中评审+" + item.SupplierName + "+" + item.SupplierTypeName + "+" + item.FullName + "+" + item.RecUnitName + "+" + item.LegalPerson + "+" + item.CommercialNo + "+" +
  893. regCapital + "+" + currency + "+" + item.CompanyType + "+" + utils.ToStr(item.SetupTime.Format("2006-01-02")) + "+" + item.Mobile + "+" + item.SubName + "+" + strings.TrimLeft(subName, ",")
  894. cellName := strings.Split(dataString, "+")
  895. row := sheet.AddRow()
  896. row.WriteSlice(&cellName, -1)
  897. }
  898. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  899. sheet.Cols[c].Width = 30
  900. }
  901. dir := "static/file/excel/report/" + this.GetAccode()
  902. SaveDirectory(dir)
  903. path := dir + "/jzps_" + utils.TimeFormat(time.Now(), "20060102") + fileTitle + ".xlsx"
  904. f.Save(path)
  905. var sw *Seaweed
  906. var filer []string
  907. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  908. filer = []string{_filer}
  909. }
  910. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  911. _, _, fID, _ := sw.UploadFile(path, "", "")
  912. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  913. os.Remove(path)
  914. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  915. this.Data["json"] = retDocUrl
  916. this.ServeJSON()
  917. }
  918. // @Title 企业入库列表
  919. // @Description get user by token
  920. // @Success 200 {object} []supplier.OilSupplier
  921. // @router /storelist [get]
  922. func (this *OilSupplierController) GetJoinStoreEntityList() {
  923. //获取分页信息
  924. page := this.GetPageInfoForm()
  925. where := " 1=1 "
  926. orderby := "Id"
  927. asc := false
  928. Order := this.GetString("Order")
  929. Prop := this.GetString("Prop")
  930. if Order != "" && Prop != "" {
  931. orderby = Prop
  932. if Order == "asc" {
  933. asc = true
  934. }
  935. }
  936. SupplierName := this.GetString("SupplierName")
  937. Grade := this.GetString("Grade")
  938. SupplierTypeName := this.GetString("SupplierTypeName")
  939. CreateOn := this.GetString("CreateOn")
  940. SupplierTypeCode := this.GetString("SupplierTypeCode")
  941. OperType := this.GetString("OperType")
  942. SpecTypeCode := this.GetString("SpecTypeCode")
  943. Country := this.GetString("Country")
  944. InStyle := this.GetString("InStyle")
  945. MgrUnit := this.GetString("MgrUnit")
  946. PACNumber := this.GetString("PACNumber")
  947. CommercialNo := this.GetString("CommercialNo")
  948. Province := this.GetString("Province")
  949. City := this.GetString("City")
  950. Street := this.GetString("Street")
  951. Address := this.GetString("Address")
  952. LinkProvince := this.GetString("LinkProvince")
  953. LinkCity := this.GetString("LinkCity")
  954. LinkStreet := this.GetString("LinkStreet")
  955. LinkAddress := this.GetString("LinkAddress")
  956. LegalPerson := this.GetString("LegalPerson")
  957. ContactName := this.GetString("ContactName")
  958. CompanyType := this.GetString("CompanyType")
  959. SetupTime := this.GetString("SetupTime")
  960. RegCapital1 := this.GetString("RegCapital1")
  961. RegCapital2 := this.GetString("RegCapital2")
  962. BusinessScope := this.GetString("BusinessScope")
  963. Code := this.GetString("Code")
  964. InFlag := this.GetString("InFlag")
  965. if SupplierName != "" {
  966. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  967. }
  968. if Grade != "" {
  969. where = where + " and a.Grade = '" + Grade + "'"
  970. }
  971. if SupplierTypeName != "" {
  972. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  973. }
  974. if CreateOn != "" {
  975. dates := strings.Split(CreateOn, ",")
  976. if len(dates) == 2 {
  977. minDate := dates[0]
  978. maxDate := dates[1]
  979. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  980. }
  981. }
  982. if SupplierTypeCode != "" {
  983. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  984. }
  985. if OperType != "" {
  986. where = where + " and a.OperType like '%" + OperType + "%'"
  987. }
  988. if SpecTypeCode != "" {
  989. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  990. }
  991. if Country != "" {
  992. where = where + " and a.Country like '%" + Country + "%'"
  993. }
  994. if InStyle != "" {
  995. where = where + " and b.InStyle ='" + InStyle + "'"
  996. }
  997. if MgrUnit != "" {
  998. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  999. }
  1000. if PACNumber != "" {
  1001. where = where + " and a.PACNumber ='" + PACNumber + "'"
  1002. }
  1003. if CommercialNo != "" {
  1004. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  1005. }
  1006. if Province != "" {
  1007. where = where + " and a.Province ='" + Province + "'"
  1008. }
  1009. if City != "" {
  1010. where = where + " and a.City ='" + City + "'"
  1011. }
  1012. if Street != "" {
  1013. where = where + " and a.Street ='" + Street + "'"
  1014. }
  1015. if Address != "" {
  1016. where = where + " and a.Address ='" + Address + "'"
  1017. }
  1018. if LinkProvince != "" {
  1019. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  1020. }
  1021. if LinkCity != "" {
  1022. where = where + " and a.LinkCity ='" + LinkCity + "'"
  1023. }
  1024. if LinkStreet != "" {
  1025. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  1026. }
  1027. if LinkAddress != "" {
  1028. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  1029. }
  1030. if LegalPerson != "" {
  1031. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  1032. }
  1033. if ContactName != "" {
  1034. where = where + " and a.ContactName ='" + ContactName + "'"
  1035. }
  1036. if CompanyType != "" {
  1037. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  1038. }
  1039. if SetupTime != "" {
  1040. where = where + " and a.SetupTime ='" + SetupTime + "'"
  1041. }
  1042. //注册资金范围
  1043. if RegCapital1 != "" {
  1044. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  1045. }
  1046. if RegCapital2 != "" {
  1047. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  1048. }
  1049. if BusinessScope != "" {
  1050. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  1051. }
  1052. status := this.GetString("Status")
  1053. if status != "" {
  1054. where = where + " and b.Status='" + status + "'"
  1055. }
  1056. if InFlag != "" {
  1057. where = where + " and b.InFlag='" + InFlag + "'"
  1058. }
  1059. //企业用户只看自己的数据记录
  1060. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  1061. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  1062. if extOrganizeId == this.User.DepartmentId {
  1063. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  1064. }*/
  1065. //企业用户必须加创建人条件
  1066. if this.User.IsCompanyUser == 1 {
  1067. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  1068. }
  1069. svc := supplier.GetOilSupplierService(utils.DBE)
  1070. var list []supplier.OilSupplierView
  1071. var Ids supplier.OilCertIds
  1072. if Code != "" {
  1073. where1 := " SupplierTypeCode = '" + SupplierTypeCode + "' and Code like '" + Code + "%'"
  1074. svc.GetCertIds(&Ids, where1)
  1075. }
  1076. total := svc.GetMyPagingEntitiesWithOrderBytbl2(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where, Code, Ids.Ids)
  1077. var datainfo DataInfo
  1078. datainfo.Items = list
  1079. datainfo.CurrentItemCount = total
  1080. datainfo.PageIndex = page.CurrentPage
  1081. datainfo.ItemsPerPage = page.Size
  1082. this.Data["json"] = &datainfo
  1083. this.ServeJSON()
  1084. }
  1085. // @Title 企业入库列表-导出
  1086. // @Description get user by token
  1087. // @Success 200 {object} []supplier.OilSupplier
  1088. // @router /exportStoreList [get]
  1089. func (this *OilSupplierController) ExportStoreList() {
  1090. //获取分页信息
  1091. where := " 1=1 "
  1092. orderby := "Id"
  1093. asc := false
  1094. Order := this.GetString("Order")
  1095. Prop := this.GetString("Prop")
  1096. if Order != "" && Prop != "" {
  1097. orderby = Prop
  1098. if Order == "asc" {
  1099. asc = true
  1100. }
  1101. }
  1102. SupplierName := this.GetString("SupplierName")
  1103. Grade := this.GetString("Grade")
  1104. SupplierTypeName := this.GetString("SupplierTypeName")
  1105. CreateOn := this.GetString("CreateOn")
  1106. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1107. OperType := this.GetString("OperType")
  1108. SpecTypeCode := this.GetString("SpecTypeCode")
  1109. Country := this.GetString("Country")
  1110. InStyle := this.GetString("InStyle")
  1111. MgrUnit := this.GetString("MgrUnit")
  1112. PACNumber := this.GetString("PACNumber")
  1113. CommercialNo := this.GetString("CommercialNo")
  1114. Province := this.GetString("Province")
  1115. City := this.GetString("City")
  1116. Street := this.GetString("Street")
  1117. Address := this.GetString("Address")
  1118. LinkProvince := this.GetString("LinkProvince")
  1119. LinkCity := this.GetString("LinkCity")
  1120. LinkStreet := this.GetString("LinkStreet")
  1121. LinkAddress := this.GetString("LinkAddress")
  1122. LegalPerson := this.GetString("LegalPerson")
  1123. ContactName := this.GetString("ContactName")
  1124. CompanyType := this.GetString("CompanyType")
  1125. SetupTime := this.GetString("SetupTime")
  1126. RegCapital1 := this.GetString("RegCapital1")
  1127. RegCapital2 := this.GetString("RegCapital2")
  1128. BusinessScope := this.GetString("BusinessScope")
  1129. Code := this.GetString("Code")
  1130. InFlag := this.GetString("InFlag")
  1131. if SupplierName != "" {
  1132. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  1133. }
  1134. if Grade != "" {
  1135. where = where + " and a.Grade = '" + Grade + "'"
  1136. }
  1137. if SupplierTypeName != "" {
  1138. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  1139. }
  1140. if CreateOn != "" {
  1141. dates := strings.Split(CreateOn, ",")
  1142. if len(dates) == 2 {
  1143. minDate := dates[0]
  1144. maxDate := dates[1]
  1145. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  1146. }
  1147. }
  1148. if SupplierTypeCode != "" {
  1149. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  1150. }
  1151. if OperType != "" {
  1152. where = where + " and a.OperType like '%" + OperType + "%'"
  1153. }
  1154. if SpecTypeCode != "" {
  1155. where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
  1156. }
  1157. if Country != "" {
  1158. where = where + " and a.Country like '%" + Country + "%'"
  1159. }
  1160. if InStyle != "" {
  1161. where = where + " and b.InStyle ='" + InStyle + "'"
  1162. }
  1163. if MgrUnit != "" {
  1164. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  1165. }
  1166. if PACNumber != "" {
  1167. where = where + " and a.PACNumber ='" + PACNumber + "'"
  1168. }
  1169. if CommercialNo != "" {
  1170. where = where + " and a.CommercialNo ='" + CommercialNo + "'"
  1171. }
  1172. if Province != "" {
  1173. where = where + " and a.Province ='" + Province + "'"
  1174. }
  1175. if City != "" {
  1176. where = where + " and a.City ='" + City + "'"
  1177. }
  1178. if Street != "" {
  1179. where = where + " and a.Street ='" + Street + "'"
  1180. }
  1181. if Address != "" {
  1182. where = where + " and a.Address ='" + Address + "'"
  1183. }
  1184. if LinkProvince != "" {
  1185. where = where + " and a.LinkProvince ='" + LinkProvince + "'"
  1186. }
  1187. if LinkCity != "" {
  1188. where = where + " and a.LinkCity ='" + LinkCity + "'"
  1189. }
  1190. if LinkStreet != "" {
  1191. where = where + " and a.LinkStreet ='" + LinkStreet + "'"
  1192. }
  1193. if LinkAddress != "" {
  1194. where = where + " and a.LinkAddress ='" + LinkAddress + "'"
  1195. }
  1196. if LegalPerson != "" {
  1197. where = where + " and a.LegalPerson ='" + LegalPerson + "'"
  1198. }
  1199. if ContactName != "" {
  1200. where = where + " and a.ContactName ='" + ContactName + "'"
  1201. }
  1202. if CompanyType != "" {
  1203. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  1204. }
  1205. if SetupTime != "" {
  1206. where = where + " and a.SetupTime ='" + SetupTime + "'"
  1207. }
  1208. //注册资金范围
  1209. if RegCapital1 != "" {
  1210. where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
  1211. }
  1212. if RegCapital2 != "" {
  1213. where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
  1214. }
  1215. if BusinessScope != "" {
  1216. where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
  1217. }
  1218. status := this.GetString("Status")
  1219. if status != "" {
  1220. where = where + " and b.Status='" + status + "'"
  1221. }
  1222. if InFlag != "" {
  1223. where = where + " and b.InFlag='" + InFlag + "'"
  1224. }
  1225. //企业用户只看自己的数据记录
  1226. /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
  1227. extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
  1228. if extOrganizeId == this.User.DepartmentId {
  1229. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  1230. }*/
  1231. //企业用户必须加创建人条件
  1232. if this.User.IsCompanyUser == 1 {
  1233. where = where + " and a.CreateUserId = '" + this.User.Id + "'"
  1234. }
  1235. svc := supplier.GetOilSupplierService(utils.DBE)
  1236. var list []supplier.OilSupplierView
  1237. var Ids supplier.OilCertIds
  1238. if Code != "" {
  1239. where1 := " SupplierTypeCode = '" + SupplierTypeCode + "' and Code like '" + Code + "%'"
  1240. svc.GetCertIds(&Ids, where1)
  1241. }
  1242. svc.GetMyPagingEntitiesWithOrderBytbl2(OilSupplierName, OilSupplierCertName, 1, 5000, orderby, asc, &list, where, Code, Ids.Ids)
  1243. fileTitle := "已入库"
  1244. showColumnArr := "序号,准入标识,准入证编号,准入类别,企业名称,有效期,工商注册号,省市县,单位地址,注册资本,币种,联系人姓名,公司类型,成立时间,开户银行,银行账号,电子邮箱,银行信用等级,移动电话,固定电话,传真,公司电话,备注"
  1245. f := xlsx.NewFile()
  1246. sheet, _ := f.AddSheet(fileTitle)
  1247. cellName := strings.Split(showColumnArr, ",")
  1248. row := sheet.AddRow()
  1249. row.WriteSlice(&cellName, -1)
  1250. for idx, item := range list {
  1251. regCapital := strconv.FormatFloat(item.RegCapital, 'f', 2, 64)
  1252. inStyle := ""
  1253. if item.InFlag == "1" {
  1254. inStyle = "准入"
  1255. } else if item.InFlag == "2" {
  1256. inStyle = "暂停"
  1257. } else if item.InFlag == "3" {
  1258. inStyle = "取消"
  1259. }
  1260. dataString := strconv.Itoa(idx+1) + "," + inStyle + "," + item.AccessCardNo + "," + item.SupplierTypeName + "," + item.SupplierName + "," +
  1261. utils.ToStr(item.ApplyTime.Format("2006-01-02")) + "," + item.CommercialNo + "," + item.AllAddress + "," + item.Address + "," + regCapital + "," + item.Currency + "," + item.ContactName + "," + item.CompanyType + "," + utils.ToStr(item.SetupTime.Format("2006-01-02")) + "," + item.DepositBank + "," + item.BankAccount + "," + item.EMail + "," + item.BankCreditRating + "," + item.Mobile + "," + item.Telphone + "," + item.Fax + "," + item.CompanyTel + "," + item.Remark
  1262. cellName := strings.Split(dataString, ",")
  1263. row := sheet.AddRow()
  1264. row.WriteSlice(&cellName, -1)
  1265. }
  1266. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  1267. sheet.Cols[c].Width = 20
  1268. }
  1269. dir := "static/file/excel/report/" + this.GetAccode()
  1270. SaveDirectory(dir)
  1271. path := dir + "/" + utils.TimeFormat(time.Now(), "20060102") + fileTitle + ".xlsx"
  1272. f.Save(path)
  1273. var sw *Seaweed
  1274. var filer []string
  1275. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1276. filer = []string{_filer}
  1277. }
  1278. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1279. _, _, fID, _ := sw.UploadFile(path, "", "")
  1280. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1281. os.Remove(path)
  1282. fmt.Println("==retDocWatermarkUrl==", retDocUrl)
  1283. this.Data["json"] = retDocUrl
  1284. this.ServeJSON()
  1285. }
  1286. // @Title 获取列表
  1287. // @Description get user by token
  1288. // @Success 200 {object} []supplier.OilSupplierView
  1289. // @router /mytasks [get]
  1290. func (this *OilSupplierController) GetMyTaskEntityList() {
  1291. //获取分页信息
  1292. page := this.GetPageInfoForm()
  1293. where := " 1=1 "
  1294. orderby := "Id"
  1295. asc := false
  1296. Order := this.GetString("Order")
  1297. //Statustype := this.GetString("Statustype")
  1298. //if Statustype != "" {
  1299. // where = " 1=1 and b.Status =" + Statustype
  1300. //}
  1301. where = where + " and b.Status>0"
  1302. Prop := this.GetString("Prop")
  1303. if Order != "" && Prop != "" {
  1304. orderby = Prop
  1305. if Order == "asc" {
  1306. asc = true
  1307. }
  1308. }
  1309. Id := this.GetString("Id")
  1310. SupplierName := this.GetString("SupplierName")
  1311. OilCertificateNo := this.GetString("OilCertificateNo")
  1312. Grade := this.GetString("Grade")
  1313. MgrUnit := this.GetString("MgrUnit")
  1314. OperType := this.GetString("OperType")
  1315. Country := this.GetString("Country")
  1316. MaunAgent := this.GetString("MaunAgent")
  1317. ConstructTeam := this.GetString("ConstructTeam")
  1318. CommercialNo := this.GetString("CommercialNo")
  1319. OrganCode := this.GetString("OrganCode")
  1320. CountryTaxNo := this.GetString("CountryTaxNo")
  1321. LocalTaxNo := this.GetString("LocalTaxNo")
  1322. Address := this.GetString("Address")
  1323. Province := this.GetString("Province")
  1324. City := this.GetString("City")
  1325. Street := this.GetString("Street")
  1326. HouseNo := this.GetString("HouseNo")
  1327. ZipCode := this.GetString("ZipCode")
  1328. QualitySystemCert := this.GetString("QualitySystemCert")
  1329. ProductQualityCert := this.GetString("ProductQualityCert")
  1330. MaunLicense := this.GetString("MaunLicense")
  1331. QualifCert := this.GetString("QualifCert")
  1332. QualifCertLevel := this.GetString("QualifCertLevel")
  1333. SafetyLicense := this.GetString("SafetyLicense")
  1334. TechServiceLic := this.GetString("TechServiceLic")
  1335. TJInNotify := this.GetString("TJInNotify")
  1336. SpecIndustryCert := this.GetString("SpecIndustryCert")
  1337. LegalPerson := this.GetString("LegalPerson")
  1338. CategoryCode := this.GetString("CategoryCode")
  1339. CategoryName := this.GetString("CategoryName")
  1340. RegCapital := this.GetString("RegCapital")
  1341. Currency := this.GetString("Currency")
  1342. ContactName := this.GetString("ContactName")
  1343. CompanyType := this.GetString("CompanyType")
  1344. SetupTime := this.GetString("SetupTime")
  1345. DepositBank := this.GetString("DepositBank")
  1346. BankAccount := this.GetString("BankAccount")
  1347. EMail := this.GetString("EMail")
  1348. BankCreditRating := this.GetString("BankCreditRating")
  1349. Mobile := this.GetString("Mobile")
  1350. Telphone := this.GetString("Telphone")
  1351. Fax := this.GetString("Fax")
  1352. CompanyTel := this.GetString("CompanyTel")
  1353. QQ := this.GetString("QQ")
  1354. CompanyUrl := this.GetString("CompanyUrl")
  1355. SpecSupplier := this.GetString("SpecSupplier")
  1356. SpecTypeCode := this.GetString("SpecTypeCode")
  1357. SpecTypeName := this.GetString("SpecTypeName")
  1358. Remark := this.GetString("Remark")
  1359. CreateOn := this.GetString("CreateOn")
  1360. SupplierTypeCode := this.GetString("SupplierTypeCode")
  1361. if Id != "" {
  1362. where = where + " and a.Id like '%" + Id + "%'"
  1363. }
  1364. if SupplierName != "" {
  1365. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  1366. }
  1367. if OilCertificateNo != "" {
  1368. where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
  1369. }
  1370. if Grade != "" {
  1371. where = where + " and a.Grade like '%" + Grade + "%'"
  1372. }
  1373. if MgrUnit != "" {
  1374. where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
  1375. }
  1376. if OperType != "" {
  1377. where = where + " and a.OperType like '%" + OperType + "%'"
  1378. }
  1379. if Country != "" {
  1380. where = where + " and a.Country like '%" + Country + "%'"
  1381. }
  1382. if MaunAgent != "" {
  1383. where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
  1384. }
  1385. if ConstructTeam != "" {
  1386. where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
  1387. }
  1388. if CommercialNo != "" {
  1389. where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
  1390. }
  1391. if OrganCode != "" {
  1392. where = where + " and a.OrganCode like '%" + OrganCode + "%'"
  1393. }
  1394. if CountryTaxNo != "" {
  1395. where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
  1396. }
  1397. if LocalTaxNo != "" {
  1398. where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
  1399. }
  1400. if Address != "" {
  1401. where = where + " and a.Address like '%" + Address + "%'"
  1402. }
  1403. if Province != "" {
  1404. where = where + " and a.Province like '%" + Province + "%'"
  1405. }
  1406. if City != "" {
  1407. where = where + " and a.City like '%" + City + "%'"
  1408. }
  1409. if Street != "" {
  1410. where = where + " and a.Street like '%" + Street + "%'"
  1411. }
  1412. if HouseNo != "" {
  1413. where = where + " and a.HouseNo like '%" + HouseNo + "%'"
  1414. }
  1415. if ZipCode != "" {
  1416. where = where + " and a.ZipCode like '%" + ZipCode + "%'"
  1417. }
  1418. if QualitySystemCert != "" {
  1419. where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
  1420. }
  1421. if ProductQualityCert != "" {
  1422. where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
  1423. }
  1424. if MaunLicense != "" {
  1425. where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
  1426. }
  1427. if QualifCert != "" {
  1428. where = where + " and a.QualifCert like '%" + QualifCert + "%'"
  1429. }
  1430. if QualifCertLevel != "" {
  1431. where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
  1432. }
  1433. if SafetyLicense != "" {
  1434. where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
  1435. }
  1436. if TechServiceLic != "" {
  1437. where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
  1438. }
  1439. if TJInNotify != "" {
  1440. where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
  1441. }
  1442. if SpecIndustryCert != "" {
  1443. where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
  1444. }
  1445. if LegalPerson != "" {
  1446. where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
  1447. }
  1448. if CategoryCode != "" {
  1449. where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
  1450. }
  1451. if CategoryName != "" {
  1452. where = where + " and a.CategoryName like '%" + CategoryName + "%'"
  1453. }
  1454. if RegCapital != "" {
  1455. where = where + " and a.RegCapital like '%" + RegCapital + "%'"
  1456. }
  1457. if Currency != "" {
  1458. where = where + " and a.Currency like '%" + Currency + "%'"
  1459. }
  1460. if ContactName != "" {
  1461. where = where + " and a.ContactName like '%" + ContactName + "%'"
  1462. }
  1463. if CompanyType != "" {
  1464. where = where + " and a.CompanyType like '%" + CompanyType + "%'"
  1465. }
  1466. if SetupTime != "" {
  1467. where = where + " and a.SetupTime like '%" + SetupTime + "%'"
  1468. }
  1469. if DepositBank != "" {
  1470. where = where + " and a.DepositBank like '%" + DepositBank + "%'"
  1471. }
  1472. if BankAccount != "" {
  1473. where = where + " and a.BankAccount like '%" + BankAccount + "%'"
  1474. }
  1475. if EMail != "" {
  1476. where = where + " and a.EMail like '%" + EMail + "%'"
  1477. }
  1478. if BankCreditRating != "" {
  1479. where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
  1480. }
  1481. if Mobile != "" {
  1482. where = where + " and a.Mobile like '%" + Mobile + "%'"
  1483. }
  1484. if Telphone != "" {
  1485. where = where + " and a.Telphone like '%" + Telphone + "%'"
  1486. }
  1487. if Fax != "" {
  1488. where = where + " and a.Fax like '%" + Fax + "%'"
  1489. }
  1490. if CompanyTel != "" {
  1491. where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
  1492. }
  1493. if QQ != "" {
  1494. where = where + " and a.QQ like '%" + QQ + "%'"
  1495. }
  1496. if CompanyUrl != "" {
  1497. where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
  1498. }
  1499. if SpecSupplier != "" {
  1500. where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
  1501. }
  1502. if SpecTypeCode != "" {
  1503. where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
  1504. }
  1505. if SpecTypeName != "" {
  1506. where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
  1507. }
  1508. if Remark != "" {
  1509. where = where + " and a.Remark like '%" + Remark + "%'"
  1510. }
  1511. if CreateOn != "" {
  1512. dates := strings.Split(CreateOn, ",")
  1513. if len(dates) == 2 {
  1514. minDate := dates[0]
  1515. maxDate := dates[1]
  1516. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  1517. }
  1518. }
  1519. if SupplierTypeCode != "" {
  1520. where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
  1521. }
  1522. //找出待办任务
  1523. actisvc := workflow.GetActivitiService(utils.DBE)
  1524. var certIdList string
  1525. str := actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  1526. if str != "" {
  1527. certIdList = str
  1528. certIdList = certIdList + ","
  1529. }
  1530. certIdList = strings.Trim(certIdList, ",")
  1531. certIdarr := strings.Split(certIdList, ",")
  1532. for i, item := range certIdarr {
  1533. idx := strings.Index(item, "-")
  1534. if idx >= 0 {
  1535. certIdarr[i] = strings.Split(item, "-")[0]
  1536. }
  1537. }
  1538. certIdList = strings.Join(certIdarr, ",")
  1539. var list []supplier.OilSupplierView
  1540. svc := supplier.GetOilSupplierService(utils.DBE)
  1541. var total int64 = 0
  1542. if certIdList != "" {
  1543. where += " and b.Id in (" + certIdList + ")"
  1544. total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  1545. }
  1546. //根据部门查询待办任务
  1547. var datainfo DataInfo
  1548. datainfo.Items = list
  1549. datainfo.CurrentItemCount = total
  1550. datainfo.PageIndex = page.CurrentPage
  1551. datainfo.ItemsPerPage = page.Size
  1552. this.Data["json"] = &datainfo
  1553. this.ServeJSON()
  1554. }
  1555. // @Title 获取字典列表
  1556. // @Description get user by token
  1557. // @Success 200 {object} map[string]interface{}
  1558. // @router /dictlist [get]
  1559. func (this *OilSupplierController) GetDictList() {
  1560. dictList := make(map[string]interface{})
  1561. dictSvc := items.GetItemsService(utils.DBE)
  1562. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1563. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1564. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1565. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1566. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1567. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1568. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1569. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1570. var userEntity userRole.Base_User
  1571. userSvc.GetEntityById(this.User.Id, &userEntity)
  1572. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1573. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1574. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1575. var ysname string
  1576. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1577. ysname = paramSvc.GetBaseparameterMessage("", "paramset", "YaSuoBao")
  1578. dictList["YaSuoName"] = ysname
  1579. //获取我创建的所有公司
  1580. var list []supplier.OilSupplier
  1581. if this.User.IsCompanyUser == 1 {
  1582. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1583. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1584. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1585. dictList["CompanyNames"] = list
  1586. } else { //二级单位不用获取
  1587. dictList["CompanyNames"] = list
  1588. }
  1589. // 部门
  1590. orgsvc := organize.GetOrganizeService(utils.DBE)
  1591. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1592. //var dictCustomer []svccustomer.Customer
  1593. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1594. //dictList["EntrustCorp"] = &dictCustomer
  1595. //获得有审核权限的人员
  1596. var users []userRole.Base_RoleList
  1597. var auditWorkflow auditsetting.Base_OilAuditSetting
  1598. rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1599. rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1600. users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1601. dictList["Auditer"] = users
  1602. // 所有专业处室
  1603. var allBusDeptList []organize.Base_Organize
  1604. //where = "Category='Unit' and ParentId in (100000001, 100000128)"
  1605. //00097005 直属机构 00265300 公司机关 00097004 机关附属机构
  1606. //where = "Category='Unit' and OuterPhone in (00097005,00265300,00097004)"
  1607. whereBus := "(Category='Unit' and ParentId in (100000009, 100000004))"
  1608. orgsvc.GetEntities(&allBusDeptList, whereBus)
  1609. dictList["AllBusDeptList"] = allBusDeptList
  1610. var datainfo DataInfo
  1611. datainfo.Items = dictList
  1612. this.Data["json"] = &datainfo
  1613. this.ServeJSON()
  1614. }
  1615. // @Title 获取字典列表By Status
  1616. // @Description get user by token
  1617. // @Success 200 {object} map[string]interface{}
  1618. // @router /dictlistbystatus/ [get]
  1619. func (this *OilSupplierController) GetDictListByStatus() {
  1620. //status := this.Ctx.Input.Param(":status")
  1621. status := this.GetString("status")
  1622. majorAduit := this.GetString("majorAduit")
  1623. addId := this.GetString("addId")
  1624. isTecContract := this.GetString("isTecContract")
  1625. dictList := make(map[string]interface{})
  1626. dictSvc := items.GetItemsService(utils.DBE)
  1627. userSvc := baseUser.GetBaseUserService(utils.DBE)
  1628. areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
  1629. orgsvc := organize.GetOrganizeService(utils.DBE)
  1630. svc := supplier.GetOilSupplierService(utils.DBE)
  1631. //customerSvc := svccustomer.GetCustomerService(utils.DBE)
  1632. dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
  1633. dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
  1634. dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
  1635. dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
  1636. dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
  1637. dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
  1638. var userEntity userRole.Base_User
  1639. userSvc.GetEntityById(this.User.Id, &userEntity)
  1640. dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
  1641. dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
  1642. dictList["CountryList"] = areaJsonSvc.GetCountryList()
  1643. //获取专业审批处室部门
  1644. var preorglist []organize.Base_Organizetree
  1645. //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1646. //topid := paramSvc.GetBaseparameterMessage("", "paramset", "HeadquartersID") // 总公司Id
  1647. ids := orgsvc.GetAllChildUnitById("0")
  1648. svc.GetProOrTreeList(ids, &preorglist)
  1649. dictList["ProOrgList"] = preorglist
  1650. var unitorglist []organize.Base_Organize
  1651. //where := "Category='Unit'and Id not in (100000004,100000003,100000002) "
  1652. //where := "Category='Unit'and Id not in (100000880,100000201) "
  1653. where := "Category='Unit'"
  1654. orgsvc.GetEntities(&unitorglist, where)
  1655. dictList["UnitOrgList"] = unitorglist
  1656. //获取我创建的所有公司
  1657. var list []supplier.OilSupplier
  1658. if this.User.IsCompanyUser == 1 {
  1659. svcSupplier := supplier.GetOilSupplierService(utils.DBE)
  1660. supplierWhere := " CreateUserId = '" + this.User.Id + "'"
  1661. svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
  1662. dictList["CompanyNames"] = list
  1663. } else { //二级单位不用获取
  1664. dictList["CompanyNames"] = list
  1665. }
  1666. // 部门
  1667. dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
  1668. //var dictCustomer []svccustomer.Customer
  1669. //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
  1670. //dictList["EntrustCorp"] = &dictCustomer
  1671. //获得有审核权限的人员
  1672. //var users []suppliercert.UserList
  1673. //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
  1674. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  1675. var users []userRole.Base_RoleList
  1676. if status == suppliercert.FIRST_TRIAL_STATUS {
  1677. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1678. //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
  1679. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1680. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1681. certSrv.GetAuditUser(this.User.DepartmentId, workflow.SECOND_TRIAL, &users)
  1682. dictList["Auditer"] = users
  1683. } else if status == suppliercert.SECOND_TRIAL_STATUS {
  1684. //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
  1685. } else if status == suppliercert.THIRD_TRIAL_STATUS {
  1686. //where := "OrganizeId=" + majorAduit + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
  1687. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1688. certSrv.GetAuditUser(majorAduit, workflow.SECOND_TRIAL, &users)
  1689. dictList["Auditer"] = users
  1690. } else if status == suppliercert.PROF_AUDIT_STATUS {
  1691. //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.PROF_AUDIT + "'"
  1692. //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
  1693. certSrv.GetAuditUser(this.User.DepartmentId, workflow.PROF_AUDIT, &users)
  1694. dictList["Auditer"] = users
  1695. } else if status == suppliercert.CENT_AUDIT_STATUS {
  1696. }
  1697. // 注册审批单位
  1698. var registermodel register.OilCorporateInfo
  1699. wherereg := "UserId=" + this.User.Id
  1700. svc.GetEntity(&registermodel, wherereg)
  1701. dictList["Register"] = registermodel
  1702. // 所有专业处室
  1703. var allunitorglist []organize.Base_Organize
  1704. //where = "Category='Unit' and ParentId in (100000001, 100000128)"
  1705. //00097005 直属机构 00265300 公司机关 00097004 机关附属机构
  1706. //where = "Category='Unit' and OuterPhone in (00097005,00265300,00097004)"
  1707. where = "(Category='Unit' and ParentId in (100000009, 100000004))"
  1708. if isTecContract == "1" {
  1709. where += " or Id = 100000656"
  1710. }
  1711. orgsvc.GetEntities(&allunitorglist, where)
  1712. dictList["Allunitorglist"] = allunitorglist
  1713. // 管理单位
  1714. var suppliermode supplier.OilSupplier
  1715. orgsvc.GetEntityById(addId, &suppliermode)
  1716. if suppliermode.MgrUnit == supplier.MGRUNIT {
  1717. dictList["MgrUnit"] = true
  1718. } else {
  1719. dictList["MgrUnit"] = false
  1720. }
  1721. //是否需要现场考察报告
  1722. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  1723. isInvestigate := paramSvc.GetBaseparameterMessage("GFGL1", "paramset", "isInvestigate")
  1724. dictList["isInvestigate"] = isInvestigate
  1725. var datainfo DataInfo
  1726. datainfo.Items = dictList
  1727. this.Data["json"] = &datainfo
  1728. this.ServeJSON()
  1729. }
  1730. // @Title 获取实体
  1731. // @Description 获取实体
  1732. // @Success 200 {object} supplier.OilSupplier
  1733. // @router /get/:id [get]
  1734. func (this *OilSupplierController) GetEntity() {
  1735. Id := this.Ctx.Input.Param(":id")
  1736. var model supplier.OilSupplier
  1737. svc := supplier.GetOilSupplierService(utils.DBE)
  1738. svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1739. this.Data["json"] = &model
  1740. this.ServeJSON()
  1741. }
  1742. // @Title 获取实体
  1743. // @Description 获取实体
  1744. // @Success 200 {object} supplier.OilSupplier
  1745. // @router /getandcert/:certId [get]
  1746. func (this *OilSupplierController) GetEntityAndCert() {
  1747. Id := this.Ctx.Input.Param(":certId")
  1748. var model supplier.OilSupplierView
  1749. //svc := supplier.GetOilSupplierService(utils.DBE)
  1750. //svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
  1751. var sql string
  1752. 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,
  1753. 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, a.Remark as Remark, b.Remark as Remark1 from ` + OilSupplierName + ` a `
  1754. sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
  1755. sql += ` where b.Id ='` + Id + `'`
  1756. utils.DBE.SQL(sql).Get(&model)
  1757. this.Data["json"] = &model
  1758. this.ServeJSON()
  1759. }
  1760. // @Title 获取实体
  1761. // @Description 获取实体
  1762. // @Success 200 {object} supplier.OilSupplier
  1763. // @router /getbyname [get]
  1764. func (this *OilSupplierController) GetEntityByName() {
  1765. name := this.GetString("name")
  1766. typecode := this.GetString("typecode")
  1767. svc := supplier.GetOilSupplierService(utils.DBE)
  1768. var model supplier.OilSupplierApply
  1769. var datainfo ErrorDataInfo
  1770. var sqlsus string
  1771. sqlsus = `select 1 from ` + OilSupplierName + ` a `
  1772. sqlsus += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id`
  1773. sqlsus += ` where a.SupplierName ='` + name + `' and b.InFlag='2' and b.SupplierTypeCode='` + typecode + `'`
  1774. var tempMap []map[string]string
  1775. tempMap, _ = svc.DBE.QueryString(sqlsus)
  1776. if tempMap != nil && tempMap[0]["1"] != "" {
  1777. datainfo.Code = -1
  1778. this.Data["json"] = &datainfo
  1779. this.ServeJSON()
  1780. } else {
  1781. var sql string
  1782. sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
  1783. sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='` + typecode + `'`
  1784. sql += ` where a.SupplierName ='` + name + `'`
  1785. utils.DBE.SQL(sql).Get(&model)
  1786. if model.SupplierName == "" {
  1787. var model2 register.OilCorporateInfo
  1788. svc.GetEntityByWhere(OilCorporateInfoName, "SupplierName='"+name+"' and CheckStatus='11'", &model2)
  1789. model2.Remark = ""
  1790. model2.Id = 0
  1791. if model2.SupplierName == "" {
  1792. datainfo.Code = -2
  1793. this.Data["json"] = &datainfo
  1794. this.ServeJSON()
  1795. } else {
  1796. datainfo.Code = 0
  1797. datainfo.Item = model2
  1798. this.Data["json"] = &datainfo
  1799. this.ServeJSON()
  1800. }
  1801. } else {
  1802. datainfo.Code = 0
  1803. datainfo.Item = model
  1804. this.Data["json"] = &datainfo
  1805. this.ServeJSON()
  1806. }
  1807. }
  1808. }
  1809. // @Title 获取实体
  1810. // @Description 判断统一社会码
  1811. // @Success 200 {object} supplier.OilSupplier
  1812. // @router /getbycomminercialno/commercialNo [get]
  1813. func (this *OilSupplierController) GetEntityComminercialNo() {
  1814. commercialNo := this.Ctx.Input.Param(":commercialNo")
  1815. svc := supplier.GetOilSupplierService(utils.DBE)
  1816. var dataInfo ErrorDataInfo
  1817. var sqlSus string
  1818. sqlSus = "select Id from OilSupplier where CommercialNo= '" + commercialNo + "'"
  1819. var tempMap []map[string]string
  1820. tempMap, _ = svc.DBE.QueryString(sqlSus)
  1821. if tempMap != nil && tempMap[0]["Id"] != "" {
  1822. dataInfo.Code = 1
  1823. this.Data["json"] = &dataInfo
  1824. this.ServeJSON()
  1825. } else {
  1826. dataInfo.Code = 0
  1827. this.Data["json"] = &dataInfo
  1828. this.ServeJSON()
  1829. }
  1830. }
  1831. // @Title 添加
  1832. // @Description 新增
  1833. // @Success 200 {object} controllers.Request
  1834. // @router /add [post]
  1835. func (this *OilSupplierController) AddEntity() {
  1836. var model supplier.OilSupplier
  1837. var modelCert suppliercert.OilSupplierCert
  1838. var modelCertVM suppliercert.OilSupplierVM
  1839. var jsonBlob = this.Ctx.Input.RequestBody
  1840. json.Unmarshal(jsonBlob, &model)
  1841. json.Unmarshal(jsonBlob, &modelCertVM)
  1842. serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  1843. var registerUser register.OilCorporateInfo
  1844. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  1845. serviceCert.GetEntity(&registerUser, sql)
  1846. canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
  1847. var errinfo ErrorDataInfo
  1848. if !canApply {
  1849. errinfo.Message = "添加失败!供方用户只能申请一次"
  1850. errinfo.Code = -1
  1851. this.Data["json"] = &errinfo
  1852. this.ServeJSON()
  1853. return
  1854. }
  1855. //判断在黑名单的不能申请准入
  1856. var black BlackList.BlackList
  1857. serviceCert.GetEntityByWhere("BlackList", "CommercialNo = '"+model.CommercialNo+"'", &black)
  1858. if black.Id > 0 {
  1859. errinfo.Message = "在黑名单内,不可申请"
  1860. errinfo.Code = -1
  1861. this.Data["json"] = &errinfo
  1862. this.ServeJSON()
  1863. return
  1864. }
  1865. var list []supplier.OilSupplierView
  1866. service := supplier.GetOilSupplierService(utils.DBE)
  1867. service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1868. if len(list) > 0 {
  1869. errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1870. errinfo.Code = -1
  1871. this.Data["json"] = &errinfo
  1872. this.ServeJSON()
  1873. return
  1874. }
  1875. //if model.Id <= 0 {
  1876. // service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1877. // if len(list) > 0 {
  1878. // errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
  1879. // errinfo.Code = -1
  1880. // this.Data["json"] = &errinfo
  1881. // this.ServeJSON()
  1882. // return
  1883. // }
  1884. //} else {
  1885. // service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1886. // if len(list) > 0 {
  1887. // errinfo.Message = "添加失败! 已存在相关企业的信息,或与其他企业信息重复"
  1888. // errinfo.Code = -1
  1889. // this.Data["json"] = &errinfo
  1890. // this.ServeJSON()
  1891. // return
  1892. // }
  1893. //}
  1894. var session *xorm.Session
  1895. session = utils.DBE.NewSession()
  1896. svc := supplier.GetOilSupplierSession(session)
  1897. svcCert := suppliercert.GetOilSupplierCertSession(session)
  1898. model.CreateOn = time.Now()
  1899. model.CreateBy = this.User.Realname
  1900. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1901. //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
  1902. defer session.Close()
  1903. err := session.Begin()
  1904. if model.Id <= 0 {
  1905. _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
  1906. } else {
  1907. //判断基本信息是否可修改
  1908. updateCols := svc.GetUpdateCols(OilSupplierCertName, modelCertVM.SupplierTypeCode, model.Id)
  1909. err = svc.UpdateEntityBytbl(OilSupplierName, model.Id, &model, updateCols)
  1910. }
  1911. if err != nil {
  1912. session.Rollback()
  1913. }
  1914. modelCert.SupplierId = model.Id
  1915. modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
  1916. modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
  1917. modelCert.InStyle = modelCertVM.InStyle
  1918. if modelCert.InStyle == suppliercert.PINGSHEN {
  1919. modelCert.IsPay = 0
  1920. } else {
  1921. modelCert.IsPay = 2
  1922. }
  1923. modelCert.Step = 1 //企业信息保存完成
  1924. modelCert.CreateOn = time.Now()
  1925. modelCert.CreateBy = this.User.Realname
  1926. modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  1927. // 保存推荐单位
  1928. if this.User.IsCompanyUser == 1 {
  1929. modelCert.RecUnitId = strconv.Itoa(registerUser.CheckUnitId)
  1930. modelCert.RecUnitName = registerUser.CheckUnitName
  1931. modelCert.RecUnitPerson = registerUser.ModifiedBy
  1932. } else {
  1933. modelCert.RecUnitId = strconv.Itoa(this.User.UnitId)
  1934. modelCert.RecUnitName = this.User.Unit
  1935. modelCert.RecUnitPerson = this.User.Realname
  1936. }
  1937. _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
  1938. if err != nil {
  1939. session.Rollback()
  1940. }
  1941. // add Commit() after all actions
  1942. err = session.Commit()
  1943. if err == nil {
  1944. //新增
  1945. errinfo.Message = "添加成功!"
  1946. errinfo.Code = 0
  1947. errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
  1948. this.Data["json"] = &errinfo
  1949. this.ServeJSON()
  1950. } else {
  1951. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  1952. errinfo.Code = -1
  1953. this.Data["json"] = &errinfo
  1954. this.ServeJSON()
  1955. }
  1956. }
  1957. // @Title 准入修改实体
  1958. // @Description 修改实体
  1959. // @Success 200 {object} controllers.Request
  1960. // @router /update/:id/:type/:instyle [post]
  1961. func (this *OilSupplierController) UpdateEntity() {
  1962. id := this.Ctx.Input.Param(":id")
  1963. typeCode := this.Ctx.Input.Param(":type")
  1964. instyle := this.Ctx.Input.Param(":instyle")
  1965. var errinfo ErrorInfo
  1966. if id == "" {
  1967. errinfo.Message = "操作失败!请求信息不完整"
  1968. errinfo.Code = -2
  1969. this.Data["json"] = &errinfo
  1970. this.ServeJSON()
  1971. return
  1972. }
  1973. var model supplier.OilSupplier
  1974. var jsonBlob = this.Ctx.Input.RequestBody
  1975. json.Unmarshal(jsonBlob, &model)
  1976. var list []supplier.OilSupplierView
  1977. service := supplier.GetOilSupplierService(utils.DBE)
  1978. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  1979. if len(list) > 0 {
  1980. errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
  1981. errinfo.Code = -1
  1982. this.Data["json"] = &errinfo
  1983. this.ServeJSON()
  1984. return
  1985. }
  1986. svc := supplier.GetOilSupplierService(utils.DBE)
  1987. model.ModifiedOn = time.Now()
  1988. model.ModifiedBy = this.User.Realname
  1989. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  1990. // 获取原本的工商注册号
  1991. var oldModel supplier.OilSupplier
  1992. svc.GetEntityById(model.Id, &oldModel)
  1993. if oldModel.SupplierName != model.SupplierName || oldModel.CommercialNo != model.CommercialNo {
  1994. cols := []string{"CommercialNo", "SupplierName"}
  1995. var info register.OilCorporateInfo
  1996. where1 := "CommercialNo = '" + oldModel.CommercialNo + "'"
  1997. svc.GetEntityByWhere(OilCorporateInfoName, where1, &info)
  1998. info.CommercialNo = model.CommercialNo
  1999. info.SupplierName = model.SupplierName
  2000. err1 := svc.UpdateEntityBywheretbl(OilCorporateInfoName, &info, cols, where1)
  2001. if err1 == nil {
  2002. var user userRole.Base_User
  2003. user.Realname = model.SupplierName
  2004. svc.UpdateEntityBywheretbl("Base_User", &user, []string{"Realname"}, "Id = "+strconv.Itoa(info.UserId))
  2005. }
  2006. }
  2007. svc1 := suppliercert.GetOilSupplierCertService(utils.DBE)
  2008. var cert suppliercert.OilSupplierCert
  2009. svc1.GetEntityByWhere(OilSupplierCertName, "SupplierId = "+id+" and SupplierTypeCode='"+typeCode+"'", &cert)
  2010. //对资质的检查
  2011. //svc1.IsSupplierCertCanSubmit(strconv.Itoa(model.Id), strconv.Itoa(cert.Id))
  2012. //判断基本信息是否可修改
  2013. updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
  2014. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
  2015. //isPay := "0"
  2016. //if instyle == suppliercert.PINGSHEN {
  2017. // isPay = "0"
  2018. //} else {
  2019. // isPay = "2"
  2020. //}
  2021. if err == nil {
  2022. svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle + "' where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'") // "', IsPay= " + isPay +
  2023. //一级变二级删除一级准入范围
  2024. if model.Grade == "2" {
  2025. svc.DeleteEntityBytbl(OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and SupplierId = "+id)
  2026. }
  2027. errinfo.Message = "修改成功!"
  2028. errinfo.Code = 0
  2029. this.Data["json"] = &errinfo
  2030. this.ServeJSON()
  2031. } else {
  2032. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  2033. errinfo.Code = -1
  2034. this.Data["json"] = &errinfo
  2035. this.ServeJSON()
  2036. }
  2037. }
  2038. // @Title 已入库列表修改实体
  2039. // @Description 修改实体
  2040. // @Success 200 {object} controllers.Request
  2041. // @router /update1/:id/:type/:instyle/:certId [post]
  2042. func (this *OilSupplierController) UpdateEntity1() {
  2043. id := this.Ctx.Input.Param(":id")
  2044. typeCode := this.Ctx.Input.Param(":type")
  2045. instyle := this.Ctx.Input.Param(":instyle")
  2046. certId := this.Ctx.Input.Param(":certId")
  2047. var errinfo ErrorInfo
  2048. if id == "" {
  2049. errinfo.Message = "操作失败!请求信息不完整"
  2050. errinfo.Code = -2
  2051. this.Data["json"] = &errinfo
  2052. this.ServeJSON()
  2053. return
  2054. }
  2055. var model supplier.OilSupplier
  2056. var model1 supplier.OilSupplierView
  2057. var jsonBlob = this.Ctx.Input.RequestBody
  2058. json.Unmarshal(jsonBlob, &model)
  2059. json.Unmarshal(jsonBlob, &model1)
  2060. model1.Remark = model1.Remark1
  2061. var list []supplier.OilSupplierView
  2062. service := supplier.GetOilSupplierService(utils.DBE)
  2063. service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
  2064. if len(list) > 0 {
  2065. errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
  2066. errinfo.Code = -1
  2067. this.Data["json"] = &errinfo
  2068. this.ServeJSON()
  2069. return
  2070. }
  2071. svc := supplier.GetOilSupplierService(utils.DBE)
  2072. model.ModifiedOn = time.Now()
  2073. model.ModifiedBy = this.User.Realname
  2074. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  2075. // 获取原本的工商注册号
  2076. var oldModel supplier.OilSupplier
  2077. svc.GetEntityById(model.Id, &oldModel)
  2078. if oldModel.SupplierName != model.SupplierName || oldModel.CommercialNo != model.CommercialNo {
  2079. cols := []string{"CommercialNo", "SupplierName"}
  2080. var info register.OilCorporateInfo
  2081. where1 := "CommercialNo = '" + oldModel.CommercialNo + "'"
  2082. svc.GetEntityByWhere(OilCorporateInfoName, where1, &info)
  2083. info.CommercialNo = model.CommercialNo
  2084. info.SupplierName = model.SupplierName
  2085. err1 := svc.UpdateEntityBywheretbl(OilCorporateInfoName, &info, cols, where1)
  2086. if err1 == nil {
  2087. var user userRole.Base_User
  2088. user.Realname = model.SupplierName
  2089. svc.UpdateEntityBywheretbl("Base_User", &user, []string{"Realname"}, "Id = "+strconv.Itoa(info.UserId))
  2090. }
  2091. }
  2092. svc1 := suppliercert.GetOilSupplierCertService(utils.DBE)
  2093. var cert suppliercert.OilSupplierCert
  2094. svc1.GetEntityByWhere(OilSupplierCertName, "SupplierId = "+id+" and SupplierTypeCode='"+typeCode+"'", &cert)
  2095. //对资质的检查
  2096. //svc1.IsSupplierCertCanSubmit(strconv.Itoa(model.Id), strconv.Itoa(cert.Id))
  2097. //判断基本信息是否可修改
  2098. updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
  2099. err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
  2100. //isPay := "0"
  2101. //if instyle == suppliercert.PINGSHEN {
  2102. // isPay = "0"
  2103. //} else {
  2104. // isPay = "2"
  2105. //}
  2106. if err == nil {
  2107. svc.UpdateEntityBytbl(OilSupplierCertName, certId, &model1, []string{"Remark"})
  2108. svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle + "' where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'") // "', IsPay= " + isPay +
  2109. //一级变二级删除一级准入范围
  2110. if model.Grade == "2" {
  2111. svc.DeleteEntityBytbl(OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and SupplierId = "+id)
  2112. }
  2113. errinfo.Message = "修改成功!"
  2114. errinfo.Code = 0
  2115. this.Data["json"] = &errinfo
  2116. this.ServeJSON()
  2117. } else {
  2118. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  2119. errinfo.Code = -1
  2120. this.Data["json"] = &errinfo
  2121. this.ServeJSON()
  2122. }
  2123. }
  2124. // @Title 修改企业人员情况实体
  2125. // @Description 修改实体
  2126. // @Success 200 {object} controllers.Request
  2127. // @router /updatenumber/:id [post]
  2128. func (this *OilSupplierController) UpdateNumberEntity() {
  2129. idGroup := this.Ctx.Input.Param(":id")
  2130. //id := strings.Split(idGroup, "_")[0]
  2131. certId := strings.Split(idGroup, "_")[1]
  2132. var errinfo ErrorInfo
  2133. if certId == "" {
  2134. errinfo.Message = "操作失败!请求信息不完整"
  2135. errinfo.Code = -2
  2136. this.Data["json"] = &errinfo
  2137. this.ServeJSON()
  2138. return
  2139. }
  2140. var modelCert suppliercert.OilSupplierCert
  2141. svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
  2142. var jsonBlob = this.Ctx.Input.RequestBody
  2143. json.Unmarshal(jsonBlob, &modelCert)
  2144. modelCert.ModifiedOn = time.Now()
  2145. modelCert.ModifiedBy = this.User.Realname
  2146. modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  2147. colcerts := []string{
  2148. "Id",
  2149. "WorkerTotal",
  2150. "ContractNum ",
  2151. "UniversityNum",
  2152. "TechnicalNum",
  2153. "AboveProfNum",
  2154. "MiddleProfNum",
  2155. "NationalRegNum",
  2156. "NationalCertTotal",
  2157. "DesignerTotal",
  2158. "SkillerTotal",
  2159. "ModifiedOn",
  2160. "ModifiedUserId",
  2161. "ModifiedBy",
  2162. }
  2163. // if modelCert.Step <= 2 {
  2164. // modelCert.Step = 2 //完成企业基本信息
  2165. // colcerts = append(colcerts, "Step")
  2166. // }
  2167. err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
  2168. if err == nil {
  2169. errinfo.Message = "保存成功!"
  2170. errinfo.Code = 0
  2171. this.Data["json"] = &errinfo
  2172. this.ServeJSON()
  2173. } else {
  2174. errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
  2175. errinfo.Code = -1
  2176. this.Data["json"] = &errinfo
  2177. this.ServeJSON()
  2178. }
  2179. }
  2180. // @Title 删除单条信息
  2181. // @Description
  2182. // @Success 200 {object} ErrorInfo
  2183. // @Failure 403 :id 为空
  2184. // @router /delete/:Id [delete]
  2185. func (this *OilSupplierController) DeleteEntity() {
  2186. Id := this.Ctx.Input.Param(":Id")
  2187. var errinfo ErrorInfo
  2188. if Id == "" {
  2189. errinfo.Message = "操作失败!请求信息不完整"
  2190. errinfo.Code = -2
  2191. this.Data["json"] = &errinfo
  2192. this.ServeJSON()
  2193. return
  2194. }
  2195. var model supplier.OilSupplier
  2196. var entityempty supplier.OilSupplier
  2197. svc := supplier.GetOilSupplierService(utils.DBE)
  2198. opdesc := "删除-" + Id
  2199. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
  2200. if err == nil {
  2201. errinfo.Message = "删除成功"
  2202. errinfo.Code = 0
  2203. this.Data["json"] = &errinfo
  2204. this.ServeJSON()
  2205. } else {
  2206. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  2207. errinfo.Code = -1
  2208. this.Data["json"] = &errinfo
  2209. this.ServeJSON()
  2210. }
  2211. }
  2212. // @Title 删除单条信息
  2213. // @Description
  2214. // @Success 200 {object} ErrorInfo
  2215. // @Failure 403 :id 为空
  2216. // @router /deleteall/:Id/:SupplierTypeCode [delete]
  2217. func (this *OilSupplierController) DeleteAllEntity() {
  2218. Id := this.Ctx.Input.Param(":Id")
  2219. SupplierTypeCode := this.Ctx.Input.Param(":SupplierTypeCode")
  2220. var errinfo ErrorInfo
  2221. if Id == "" {
  2222. errinfo.Message = "操作失败!请求信息不完整"
  2223. errinfo.Code = -2
  2224. this.Data["json"] = &errinfo
  2225. this.ServeJSON()
  2226. return
  2227. }
  2228. svc := supplier.GetOilSupplierService(utils.DBE)
  2229. deleteWhere := "SupplierId=" + Id + " and SupplierTypeCode='" + SupplierTypeCode + "'"
  2230. err := svc.DeleteEntityBytbl(OilSupplierCertSubName, deleteWhere)
  2231. err = svc.DeleteEntityBytbl(OilSupplierFileName, deleteWhere)
  2232. var modelList []suppliercert.OilSupplierCert
  2233. svc.GetEntityByWhere(OilSupplierCertName, deleteWhere, &modelList)
  2234. // 删除工作流
  2235. activitiService := workflow.GetActivitiService(utils.DBE)
  2236. var deleteProcessVM workflow.DeleteProcessVM
  2237. for _, supplierCertItem := range modelList {
  2238. // 按条件查询,正常情况下只有一条
  2239. if supplierCertItem.WorkflowId != "" && supplierCertItem.WorkflowId != "0" {
  2240. deleteProcessVM.ProcessInstanceId = supplierCertItem.WorkflowId
  2241. deleteProcessVM.DeleteReason = "审批未通过,删除"
  2242. activitiService.DeleteComplete(deleteProcessVM)
  2243. }
  2244. }
  2245. // 删除SupplierCert表
  2246. err = svc.DeleteEntityBytbl(OilSupplierCertName, deleteWhere)
  2247. /* var model2 suppliercert.OilSupplierCert
  2248. count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
  2249. if count2 == 0 {
  2250. err = svc.DeleteEntityBytbl(OilSupplierName, "Id="+Id)
  2251. } */
  2252. if err == nil {
  2253. errinfo.Message = "删除成功"
  2254. errinfo.Code = 0
  2255. this.Data["json"] = &errinfo
  2256. this.ServeJSON()
  2257. } else {
  2258. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  2259. errinfo.Code = -1
  2260. this.Data["json"] = &errinfo
  2261. this.ServeJSON()
  2262. }
  2263. }
  2264. // @Title 判断是否可以申请准入
  2265. // @Description
  2266. // @Success 200 {string} Count
  2267. // @Failure 403 :id 为空
  2268. // @router /iscanapply/:type [get]
  2269. func (this *OilSupplierController) IsCanApply() {
  2270. Type := this.Ctx.Input.Param(":type")
  2271. var errinfo ErrorInfo
  2272. if Type == "" {
  2273. errinfo.Message = "操作失败!请求信息不完整"
  2274. errinfo.Code = -2
  2275. this.Data["json"] = &errinfo
  2276. this.ServeJSON()
  2277. return
  2278. }
  2279. svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  2280. var registerUser register.OilCorporateInfo
  2281. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  2282. svc.GetEntity(&registerUser, sql)
  2283. canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
  2284. if canApply {
  2285. //判断是否是暂停
  2286. if this.User.IsCompanyUser == 1 {
  2287. var tempMap []map[string]string
  2288. 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 + "'"
  2289. tempMap, _ = svc.DBE.QueryString(sql)
  2290. if tempMap != nil && tempMap[0]["1"] != "" {
  2291. errinfo.Message = "已暂停,不可申请"
  2292. errinfo.Code = -2
  2293. this.Data["json"] = &errinfo
  2294. this.ServeJSON()
  2295. } else {
  2296. errinfo.Message = "无申请记录,可以申请"
  2297. errinfo.Code = 0
  2298. this.Data["json"] = &errinfo
  2299. this.ServeJSON()
  2300. }
  2301. } else {
  2302. errinfo.Message = "无申请记录,可以申请"
  2303. errinfo.Code = 0
  2304. this.Data["json"] = &errinfo
  2305. this.ServeJSON()
  2306. }
  2307. } else {
  2308. errinfo.Message = "供方用户只能申请一次"
  2309. errinfo.Code = -1
  2310. this.Data["json"] = &errinfo
  2311. this.ServeJSON()
  2312. }
  2313. }
  2314. // @Title 判断是否可以修改供方企业信息
  2315. // @Description
  2316. // @Success 200 {string} Count
  2317. // @Failure 403 :id 为空
  2318. // @router /iscanupdatesupplier/:supplierid/:typecode [get]
  2319. func (this *OilSupplierController) CanUpdateSupplier() {
  2320. supplierId := this.Ctx.Input.Param(":supplierid")
  2321. typeCode := this.Ctx.Input.Param(":typecode")
  2322. var errinfo ErrorInfo
  2323. if supplierId == "" {
  2324. errinfo.Message = "操作失败!请求信息不完整"
  2325. errinfo.Code = -2
  2326. this.Data["json"] = &errinfo
  2327. this.ServeJSON()
  2328. return
  2329. }
  2330. Id, _ := strconv.Atoi(supplierId)
  2331. svc := supplier.GetOilSupplierService(utils.DBE)
  2332. canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id, typeCode) // 区分物资类01 基建类02 服务类03
  2333. if canUpdate {
  2334. errinfo.Message = "可以修改"
  2335. errinfo.Code = 0
  2336. this.Data["json"] = &errinfo
  2337. this.ServeJSON()
  2338. } else {
  2339. errinfo.Message = "此供方已经提交准入申请,不可修改"
  2340. errinfo.Code = -1
  2341. this.Data["json"] = &errinfo
  2342. this.ServeJSON()
  2343. }
  2344. }
  2345. // @Title 获取二级审核人员
  2346. // @Description 获取二级审核人员
  2347. // @router /getauditerbydept/:deptId [get]
  2348. func (this *OilSupplierController) GetAuditerByDept() {
  2349. Id := this.Ctx.Input.Param(":deptId")
  2350. auditstepcode := this.GetString("auditstepcode")
  2351. svc := organize.GetOrganizeService(utils.DBE)
  2352. unitId := svc.GetMyUnitDepartmentId(Id)
  2353. //ids := svc.GetAllChildById(unitId)
  2354. //
  2355. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  2356. //var users []userRole.Base_RoleList
  2357. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  2358. var userlist []userRole.Base_User
  2359. var setting auditsetting.Base_OilAuditSetting
  2360. usvc := userRole.GetUserService(utils.DBE)
  2361. where := "AuditStepCode='" + auditstepcode + "'"
  2362. svc.GetEntity(&setting, where)
  2363. ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  2364. tempstr := strings.Join(ids, ",")
  2365. userIds := strings.Replace(tempstr, "uid_", "", -1)
  2366. userIds = strings.Trim(userIds, ",")
  2367. if userIds != "" {
  2368. where := "Id in (" + userIds + ")" + " and UnitId=" + unitId
  2369. svc.GetEntities(&userlist, where)
  2370. }
  2371. var datainfo ErrorDataInfo
  2372. datainfo.Item = userlist
  2373. this.Data["json"] = &datainfo
  2374. this.ServeJSON()
  2375. }
  2376. // @Title 获取二级初审人员
  2377. // @Description 获取二级初审人员
  2378. // @router /getfirauditerbydept/:deptId [get]
  2379. func (this *OilSupplierController) GetFirAuditerByDept() {
  2380. Id := this.Ctx.Input.Param(":deptId")
  2381. auditstepcode := this.GetString("auditstepcode")
  2382. var userlist []userRole.Base_User
  2383. var setting auditsetting.Base_OilAuditSetting
  2384. svc := userRole.GetUserService(utils.DBE)
  2385. where := "AuditStepCode='" + auditstepcode + "'"
  2386. svc.GetEntity(&setting, where)
  2387. svcdepartment := organize.GetOrganizeService(utils.DBE)
  2388. unitId := svcdepartment.GetMyUnitDepartmentId(this.User.DepartmentId)
  2389. alldep := svcdepartment.GetAllChildById(unitId)
  2390. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  2391. tempstr := strings.Join(ids, ",")
  2392. userIds := strings.Replace(tempstr, "uid_", "", -1)
  2393. userIds = strings.Trim(userIds, ",")
  2394. if userIds != "" {
  2395. // 企管法规处
  2396. if unitId == "100000650" {
  2397. where := "Id in (" + userIds + ")"
  2398. svc.GetEntities(&userlist, where)
  2399. } else {
  2400. where := "Id in (" + userIds + ")" + "and (UnitId=" + Id + " or Departmentid in (" + alldep + ")) "
  2401. svc.GetEntities(&userlist, where)
  2402. }
  2403. }
  2404. //svc := organize.GetOrganizeService(utils.DBE)
  2405. //
  2406. //ids := svc.GetAllChildById(Id)
  2407. //
  2408. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  2409. //var users []userRole.Base_RoleList
  2410. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  2411. var datainfo ErrorDataInfo
  2412. datainfo.Item = userlist
  2413. this.Data["json"] = &datainfo
  2414. this.ServeJSON()
  2415. }
  2416. // @Title 获取二级复审人员根据初审人员
  2417. // @Description 获取二级复审人员根据初审人员
  2418. // @router /getauditerbyfirst/:firstId [get]
  2419. func (this *OilSupplierController) GetAuditerByFist() {
  2420. Id := this.Ctx.Input.Param(":firstId")
  2421. auditstepcode := this.GetString("auditstepcode")
  2422. certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  2423. //orgSrv := organize.GetOrganizeService(utils.DBE)
  2424. var userentity userRole.Base_User
  2425. certSrv.GetEntityById(Id, &userentity)
  2426. var userlist []userRole.Base_User
  2427. var setting auditsetting.Base_OilAuditSetting
  2428. svc := userRole.GetUserService(utils.DBE)
  2429. where := "AuditStepCode='" + auditstepcode + "'"
  2430. svc.GetEntity(&setting, where)
  2431. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  2432. tempstr := strings.Join(ids, ",")
  2433. userIds := strings.Replace(tempstr, "uid_", "", -1)
  2434. userIds = strings.Trim(userIds, ",")
  2435. if userIds != "" {
  2436. where := "Id in (" + userIds + ")" + "and UnitId=" + strconv.Itoa(userentity.UnitId)
  2437. svc.GetEntities(&userlist, where)
  2438. }
  2439. //svc := organize.GetOrganizeService(utils.DBE)
  2440. //unitId := svc.GetMyUnitDepartmentId(userentity.Departmentid)
  2441. //ids := svc.GetAllChildById(unitId)
  2442. ////depId := strings.Split(userentity.Superior,",")
  2443. //var users []userRole.Base_RoleList
  2444. //certSrv.GetAuditUser(ids, auditstepcode, &users)
  2445. var datainfo ErrorDataInfo
  2446. datainfo.Item = userlist
  2447. this.Data["json"] = &datainfo
  2448. this.ServeJSON()
  2449. }
  2450. // @Title 获取二级初审人员(不需要验证登录)
  2451. // @Description 获取二级初审人员(不需要验证登录)
  2452. // @router /getauditerbydeptandnologin [get]
  2453. func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
  2454. Id := this.GetString("deptId")
  2455. auditstepcode := this.GetString("auditstepcode")
  2456. var userlist []userRole.Base_User
  2457. var setting auditsetting.Base_OilAuditSetting
  2458. svc := userRole.GetUserService(utils.DBE)
  2459. where := "AuditStepCode='" + auditstepcode + "'"
  2460. svc.GetEntity(&setting, where)
  2461. ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
  2462. tempstr := strings.Join(ids, ",")
  2463. userIds := strings.Replace(tempstr, "uid_", "", -1)
  2464. userIds = strings.Trim(userIds, ",")
  2465. if userIds != "" {
  2466. where := "Id in (" + userIds + ")" + "and UnitId=" + Id
  2467. svc.GetEntities(&userlist, where)
  2468. }
  2469. //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
  2470. //var users []userRole.Base_RoleList
  2471. //certSrv.GetAuditUser(Id, auditstepcode, &users)
  2472. // certSrv.GetAuditUserByNoLogin(Id, &users)
  2473. var datainfo ErrorDataInfo
  2474. datainfo.Item = userlist
  2475. this.Data["json"] = &datainfo
  2476. this.ServeJSON()
  2477. }
  2478. // @Title
  2479. // @Description
  2480. // @router /getjurisdiction [get]
  2481. func (this *OilSupplierController) GetJurisdiction() {
  2482. svcPerm := permission.GetPermissionService(utils.DBE)
  2483. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_delete")
  2484. var datainfo ErrorDataInfo
  2485. datainfo.Item = isauth
  2486. this.Data["json"] = &datainfo
  2487. this.ServeJSON()
  2488. }
  2489. // @Title 获取列表
  2490. // @Description get user by token
  2491. // @Success 200 {object} []supplier.OilSupplier
  2492. // @router /certlistinterface [get]
  2493. func (this *OilSupplierController) GetEntityListInterface() {
  2494. //获取分页信息
  2495. //page := this.GetPageInfoForm()
  2496. where := " 1=1 "
  2497. //orderby := "Id"
  2498. //asc := false
  2499. //Order := this.GetString("Order")
  2500. //Prop := this.GetString("Prop")
  2501. //if Order != "" && Prop != "" {
  2502. // orderby = Prop
  2503. // if Order == "asc" {
  2504. // asc = true
  2505. // }
  2506. //}
  2507. status := this.GetString("status")
  2508. if status == "1" {
  2509. where += "b.InStyle='1'"
  2510. } else if status == "2" {
  2511. where += "b.InStyle='4'"
  2512. } else if status == "3" {
  2513. where += "b.InStyle='5'"
  2514. } else if status == "4" {
  2515. where += "b.InStyle=''"
  2516. } else if status == "5" {
  2517. where += "b.InStyle=''"
  2518. }
  2519. svc := supplier.GetOilSupplierService(utils.DBE)
  2520. var interfaceData []supplier.InterfaceData
  2521. err := svc.GetInterfaceData(OilSupplierName, OilSupplierFileName, &interfaceData, where)
  2522. var errinfo ErrorDataInfo
  2523. if err == nil {
  2524. errinfo.Message = "成功!"
  2525. errinfo.Code = 0
  2526. errinfo.Item = &interfaceData
  2527. this.Data["json"] = &errinfo
  2528. this.ServeJSON()
  2529. } else {
  2530. errinfo.Message = "失败!"
  2531. errinfo.Code = -1
  2532. this.Data["json"] = &errinfo
  2533. this.ServeJSON()
  2534. }
  2535. }
  2536. // @Title 获取实体
  2537. // @Description 获取实体
  2538. // @Success 200 {object} supplier.OilSupplier
  2539. // @router /getentitybycommercialno/:commercialNo [get]
  2540. func (this *OilSupplierController) GetEntityByCommercialNo() {
  2541. commercialNo := this.Ctx.Input.Param(":commercialNo")
  2542. where := "CommercialNo = '" + commercialNo + "'"
  2543. var model supplier.OilSupplier
  2544. svc := supplier.GetOilSupplierService(utils.DBE)
  2545. svc.GetEntityByWhere(OilSupplierName, where, &model)
  2546. this.Data["json"] = &model
  2547. this.ServeJSON()
  2548. }
  2549. // @Title 更新文件上传
  2550. // @Description 更新文件上传
  2551. // @Param id path string true
  2552. // @Success 200 {object}
  2553. // @router /editsubfile/:id [put]
  2554. func (this *OilSupplierController) EditSubfile() {
  2555. id := this.Ctx.Input.Param(":id")
  2556. var errinfo ErrorInfo
  2557. if id == "" {
  2558. errinfo.Message = "操作失败!请求信息不完整"
  2559. errinfo.Code = -2
  2560. this.Data["json"] = &errinfo
  2561. this.ServeJSON()
  2562. return
  2563. }
  2564. var model supplierscenefile.OilSupplierSceneFile
  2565. var jsonblob = this.Ctx.Input.RequestBody
  2566. json.Unmarshal(jsonblob, &model)
  2567. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  2568. model.FileUrl = strings.Trim(model.FileUrl, "$")
  2569. model.FileName = strings.Trim(model.FileName, "$")
  2570. model.CreateOn = time.Now()
  2571. model.CreateBy = this.User.Realname
  2572. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2573. where := "SupplierId=" + id
  2574. svc.DeleteEntityBytbl(OilSupplierSceneFileName, where)
  2575. _, err := svc.InsertEntity(&model)
  2576. if err == nil {
  2577. errinfo.Message = "操作成功!"
  2578. errinfo.Code = 0
  2579. this.Data["json"] = &errinfo
  2580. this.ServeJSON()
  2581. } else {
  2582. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  2583. errinfo.Code = -1
  2584. this.Data["json"] = &errinfo
  2585. this.ServeJSON()
  2586. }
  2587. }
  2588. // @Title 更新文件上传
  2589. // @Description 更新文件上传copy
  2590. // @Param id path string true
  2591. // @Success 200 {object}
  2592. // @router /editsubfilecopy/:id [put]
  2593. func (this *OilSupplierController) EditSubfileCopy() {
  2594. id := this.Ctx.Input.Param(":id")
  2595. var errinfo ErrorInfo
  2596. if id == "" {
  2597. errinfo.Message = "操作失败!请求信息不完整"
  2598. errinfo.Code = -2
  2599. this.Data["json"] = &errinfo
  2600. this.ServeJSON()
  2601. return
  2602. }
  2603. var model supplierscenefile.OilSupplierSceneFile
  2604. var jsonblob = this.Ctx.Input.RequestBody
  2605. json.Unmarshal(jsonblob, &model)
  2606. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  2607. model.FileUrl = strings.Trim(model.FileUrl, "$")
  2608. model.FileName = strings.Trim(model.FileName, "$")
  2609. model.CreateOn = time.Now()
  2610. model.CreateBy = this.User.Realname
  2611. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  2612. _, err := svc.InsertEntity(&model)
  2613. if err == nil {
  2614. errinfo.Message = "操作成功!"
  2615. errinfo.Code = 0
  2616. this.Data["json"] = &errinfo
  2617. this.ServeJSON()
  2618. } else {
  2619. errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
  2620. errinfo.Code = -1
  2621. this.Data["json"] = &errinfo
  2622. this.ServeJSON()
  2623. }
  2624. }
  2625. // @Title 删除单条信息
  2626. // @Description
  2627. // @Success 200 {object} ErrorInfo
  2628. // @Failure 403 :id 为空
  2629. // @router /editsubfiledelete/:Id [delete]
  2630. func (this *OilSupplierController) EditSubfileDelete() {
  2631. Id := this.Ctx.Input.Param(":Id")
  2632. var errinfo ErrorInfo
  2633. if Id == "" {
  2634. errinfo.Message = "操作失败!请求信息不完整"
  2635. errinfo.Code = -2
  2636. this.Data["json"] = &errinfo
  2637. this.ServeJSON()
  2638. return
  2639. }
  2640. var model supplierscenefile.OilSupplierSceneFile
  2641. var model1 supplierscenefile.OilSupplierSceneFile
  2642. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  2643. opdesc := "删除-" + Id
  2644. err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierSceneFileName, BaseOperationLogName, Id, &model, &model1, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "考察报告删除")
  2645. if err == nil {
  2646. errinfo.Message = "删除成功"
  2647. errinfo.Code = 0
  2648. this.Data["json"] = &errinfo
  2649. this.ServeJSON()
  2650. } else {
  2651. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  2652. errinfo.Code = -1
  2653. this.Data["json"] = &errinfo
  2654. this.ServeJSON()
  2655. }
  2656. }
  2657. // @Title get 导入excel
  2658. // @Description get SampleType by token
  2659. // @Success 200 {object} sampletype.SampleType
  2660. // @router /importexcel [get]
  2661. func (this *OilSupplierController) ImportExcel() {
  2662. url := this.GetString("ExcelUrl")
  2663. var errorinfo ErrorInfo
  2664. if url == "" {
  2665. errorinfo.Code = -2
  2666. errorinfo.Message = "导入失败!"
  2667. this.Data["json"] = &errorinfo
  2668. this.ServeJSON()
  2669. }
  2670. svc := supplier.GetOilSupplierService(utils.DBE)
  2671. log.Printf("url:==" + url) // http://60.30.245.229//upfile/dc1/2,063156edd288
  2672. extranetIP := utils.Cfg.MustValue("server", "extranetIP")
  2673. localIP := utils.Cfg.MustValue("server", "localIP")
  2674. if strings.Index(url, extranetIP) >= 0 {
  2675. url = strings.Replace(url, extranetIP, localIP, 1)
  2676. }
  2677. _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
  2678. filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
  2679. url = strings.Replace(url, "60.30.245.229", "10.76.248.23", -1)
  2680. utils.DownloadFile(url, filename, _dir)
  2681. t := time.Now()
  2682. filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
  2683. xlFile, err := xlsx.OpenFile(filePath)
  2684. //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
  2685. if err != nil {
  2686. fmt.Printf("open failed: %s\n", err)
  2687. }
  2688. var sheet = xlFile.Sheets[0]
  2689. var errLineNum string
  2690. for i := 1; i < len(sheet.Rows); i++ {
  2691. lineNo := strconv.Itoa(i + 1)
  2692. if len(sheet.Rows[i].Cells) != 0 {
  2693. this.OperationCell(svc, lineNo, sheet.Rows[i].Cells, &errLineNum)
  2694. }
  2695. }
  2696. os.Remove(filePath)
  2697. if errLineNum != "" {
  2698. errorinfo.Code = -1
  2699. errorinfo.Message = "导入失败!错误行号:" + errLineNum
  2700. this.Data["json"] = &errorinfo
  2701. this.ServeJSON()
  2702. } else {
  2703. elapsed := time.Since(t)
  2704. log.Println(elapsed)
  2705. errorinfo.Code = 0
  2706. errorinfo.Message = "导入成功!"
  2707. this.Data["json"] = &errorinfo
  2708. this.ServeJSON()
  2709. }
  2710. }
  2711. func (this *OilSupplierController) OperationCell(svc *supplier.OilSupplierService, lineNo string, cellsArr []*xlsx.Cell, errLineNum *string) {
  2712. defer func() {
  2713. if err := recover(); err != nil {
  2714. log.Println("err"+lineNo, err)
  2715. *errLineNum += lineNo + ","
  2716. }
  2717. }()
  2718. cells := cellsArr
  2719. supplierName := strings.TrimSpace(cells[0].Value)
  2720. oilCertificateNo := ""
  2721. if len(cells) >= 2 {
  2722. oilCertificateNo = strings.TrimSpace(cells[1].Value)
  2723. }
  2724. cols := []string{"PACNumber"}
  2725. var entity supplier.OilSupplier
  2726. entity.PACNumber = oilCertificateNo
  2727. where := "SupplierName='" + supplierName + "'"
  2728. err := svc.UpdateEntityBywheretbl(OilSupplierName, &entity, cols, where)
  2729. if err != nil {
  2730. panic(err)
  2731. }
  2732. }
  2733. // @Title 获取列表
  2734. // @Description get user by token
  2735. // @Success 200 {object} []supplier.OilSupplier
  2736. // @router /getscenefilelist [get]
  2737. func (this *OilSupplierController) GetSceneFileList() {
  2738. supplierId := this.GetString("SupplierId")
  2739. page := this.GetPageInfoForm()
  2740. orderby := "Id"
  2741. var model []supplierscenefile.OilSupplierSceneFile
  2742. svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
  2743. where := "SupplierId=" + supplierId
  2744. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, true, &model, where)
  2745. var errinfo ErrorDataInfo
  2746. errinfo.Item = model
  2747. errinfo.Code = 1
  2748. this.Data["json"] = &errinfo
  2749. this.ServeJSON()
  2750. }
  2751. // @Title 获取已使用的银行账号
  2752. // @Description
  2753. // @Success 200 {object} controllers.Request
  2754. // @router /getBankAccount [get]
  2755. func (this *OilSupplierController) GetBankAccountIsExist() {
  2756. bankAccount := this.GetString("bankAccount")
  2757. supplierId := this.GetString("supId")
  2758. sqlStr := "SELECT BankAccount FROM OilSupplier where BankAccount='" + bankAccount + "'"
  2759. if supplierId != "" {
  2760. sqlStr += " and Id !=" + supplierId
  2761. }
  2762. svc := supplier.GetOilSupplierService(utils.DBE)
  2763. list, _ := svc.DBE.QueryString(sqlStr)
  2764. var errorInfo ErrorDataInfo
  2765. if list != nil {
  2766. errorInfo.Item = true
  2767. this.Data["json"] = &errorInfo
  2768. this.ServeJSON()
  2769. } else {
  2770. errorInfo.Item = false
  2771. this.Data["json"] = &errorInfo
  2772. this.ServeJSON()
  2773. }
  2774. }
  2775. // @Title 获取已使用的统一社会信用代码
  2776. // @Description
  2777. // @Success 200 {object} controllers.Request
  2778. // @router /getCommercialNo [get]
  2779. func (this *OilSupplierController) GetCommercialNoIsExist() {
  2780. commercialNo := this.GetString("commercialNo")
  2781. supplierId := this.GetString("supId")
  2782. sqlStr := "SELECT CommercialNo FROM OilSupplier where CommercialNo='" + commercialNo + "'"
  2783. if supplierId != "" {
  2784. sqlStr += " and Id !=" + supplierId
  2785. }
  2786. svc := supplier.GetOilSupplierService(utils.DBE)
  2787. list, _ := svc.DBE.QueryString(sqlStr)
  2788. var errorInfo ErrorDataInfo
  2789. if list != nil {
  2790. errorInfo.Item = true
  2791. this.Data["json"] = &errorInfo
  2792. this.ServeJSON()
  2793. } else {
  2794. errorInfo.Item = false
  2795. this.Data["json"] = &errorInfo
  2796. this.ServeJSON()
  2797. }
  2798. }
  2799. // @Title 信息变更检查资质
  2800. // @Description
  2801. // @Success 200 {object} controllers.Request
  2802. // @router /checkSupplierFile [post]
  2803. func (this *OilSupplierController) CheckSupplierFile() {
  2804. var file supplierfile.File
  2805. var jsonBlob = this.Ctx.Input.RequestBody
  2806. json.Unmarshal(jsonBlob, &file)
  2807. //获取主表信息
  2808. var supplierEntity supplier.OilSupplier
  2809. var errinfo ErrorDataInfo
  2810. supplierService := supplier.GetOilSupplierService(utils.DBE)
  2811. supplierService.GetEntityById(file.SupplierId, &supplierEntity)
  2812. //获取准入信息表
  2813. var supplierCertEntity []suppliercert.OilSupplierCert
  2814. // 查询出已有哪些资质
  2815. var tableheaderList []qualchange.OilQualChangeDetail1
  2816. fileSql := "SELECT * from OilSupplierFile WHERE SupplierId = " + strconv.Itoa(file.SupplierId)
  2817. svcHeader := tableheader.GetTableHeaderService(utils.DBE)
  2818. svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
  2819. var companyHasHeaders string
  2820. for _, tableheader := range tableheaderList {
  2821. companyHasHeaders += tableheader.NeedFileType + ","
  2822. }
  2823. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  2824. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  2825. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  2826. supplierService.GetEntitysByWhere("OilSupplierCert", "SupplierId = "+strconv.Itoa(file.SupplierId), &supplierCertEntity)
  2827. for _, cert := range supplierCertEntity {
  2828. //对准入范围的判断
  2829. var certSubList []suppliercertsub.OilSupplierCertSub
  2830. certsubService := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  2831. certsubService.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = "+strconv.Itoa(cert.Id)+" and Type != '2'", &certSubList)
  2832. idString := ""
  2833. idString1 := ""
  2834. for i := 0; i < len(certSubList); i = i + 1000 {
  2835. var ids suppliercertsub.Ids
  2836. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 3, strconv.Itoa(i))
  2837. if ids.Id != "" {
  2838. idString += "," + ids.Id
  2839. } else {
  2840. break
  2841. }
  2842. }
  2843. var needList []supplierfile.FileList
  2844. var needList1 []supplierfile.FileList
  2845. if cert.SupplierTypeCode == "01" {
  2846. //需要的资质
  2847. needList = filesvc.GetGoodsNeedFileListNew(idString, "2")
  2848. if file.Type == 1 { //制造商
  2849. idString = ""
  2850. //如果是制造商,准入范围按照各项准入范围的类型判断
  2851. for i := 0; i < len(certSubList); i = i + 1000 {
  2852. var ids suppliercertsub.Ids
  2853. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1, strconv.Itoa(i))
  2854. if ids.Id != "" {
  2855. idString += "," + ids.Id
  2856. } else {
  2857. break
  2858. }
  2859. }
  2860. for i := 0; i < len(certSubList); i = i + 1000 {
  2861. var ids1 suppliercertsub.Ids
  2862. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2, strconv.Itoa(i))
  2863. if ids1.Id != "" {
  2864. idString1 += "," + ids1.Id
  2865. } else {
  2866. break
  2867. }
  2868. }
  2869. needList = filesvc.GetGoodsNeedFileListNew(idString, "1")
  2870. needList1 = filesvc.GetGoodsNeedFileListNew(idString1, "2")
  2871. var needFile supplierfile.FileList
  2872. // 质量管理体系认证证书
  2873. CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
  2874. needFile.FileName = CNPCrenkezhengshu
  2875. needList = append(needList, needFile)
  2876. for _, need := range needList1 {
  2877. needList = append(needList, need)
  2878. }
  2879. }
  2880. } else if cert.SupplierTypeCode == "02" {
  2881. needList = filesvc.GetBasicNeedFileListNew(idString)
  2882. } else if cert.SupplierTypeCode == "03" {
  2883. needList = filesvc.GetTechNeedFileListNew(idString)
  2884. }
  2885. //if cert.InStyle == "4" {
  2886. // var needFile supplierfile.FileList
  2887. // //战略合作协议扫描件
  2888. // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  2889. // needList = append(needList, needFile)
  2890. //}
  2891. if cert.InStyle == "6" {
  2892. var needFile supplierfile.FileList
  2893. //招标准入需提供招标中标结果
  2894. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "TheTender")
  2895. needList = append(needList, needFile)
  2896. }
  2897. for _, needHeader := range needList {
  2898. if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
  2899. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  2900. //三证合一或五证合一的证件,不需要验证了
  2901. continue
  2902. }
  2903. var fileist1 supplierfile.OilSupplierFile
  2904. where1 := " SupplierId = '" + strconv.Itoa(file.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
  2905. filesvc.GetEntityByWhere("OilSupplierFile", where1, &fileist1)
  2906. var filelist2 qualchange.OilQualChangeDetail
  2907. where2 := " SupplierId = '" + strconv.Itoa(file.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
  2908. svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  2909. svc2.GetEntityByWhere("OilQualChangeDetail", where2, &filelist2)
  2910. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  2911. errinfo.Message = "请上传!" + needHeader.FileName + "! 详情请点击检查资质按钮查看!"
  2912. errinfo.Code = 0
  2913. this.Data["json"] = &errinfo
  2914. this.ServeJSON()
  2915. return
  2916. }
  2917. }
  2918. }
  2919. errinfo.Code = 1
  2920. this.Data["json"] = &errinfo
  2921. this.ServeJSON()
  2922. }
  2923. // @Title 准入/增项/年审/已入库保存检查资质方法
  2924. // @Description
  2925. // @Success 200 {object} controllers.Request
  2926. // @router /checkSupplierFileNew [post]
  2927. func (this *OilSupplierController) CheckSupplierFileNew() {
  2928. var file supplierfile.CheckFile
  2929. var jsonBlob = this.Ctx.Input.RequestBody
  2930. json.Unmarshal(jsonBlob, &file)
  2931. //获取主表信息
  2932. var supplierEntity supplier.OilSupplier
  2933. var errinfo ErrorDataInfo
  2934. supplierService := supplier.GetOilSupplierService(utils.DBE)
  2935. supplierService.GetEntityById(file.SupplierId, &supplierEntity)
  2936. //获取准入信息表
  2937. var cert suppliercert.OilSupplierCert
  2938. supplierService.GetEntityByWhere("OilSupplierCert", "Id = "+file.CertId, &cert)
  2939. // 查询出已有哪些资质
  2940. var tableheaderList []qualchange.OilQualChangeDetail1
  2941. fileSql := "SELECT * from OilSupplierFile WHERE SupplierId = " + strconv.Itoa(file.SupplierId)
  2942. svcHeader := tableheader.GetTableHeaderService(utils.DBE)
  2943. svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
  2944. var companyHasHeaders string
  2945. for _, tableheader := range tableheaderList {
  2946. companyHasHeaders += tableheader.NeedFileType + ","
  2947. }
  2948. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  2949. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  2950. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  2951. var certSubList []suppliercertsub.OilSupplierCertSub
  2952. certsubService := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  2953. certsubService.GetListByCertId(strconv.Itoa(cert.Id), &certSubList)
  2954. idString := ""
  2955. idString1 := ""
  2956. for i := 0; i < len(certSubList); i = i + 1000 {
  2957. var ids suppliercertsub.Ids
  2958. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 3, strconv.Itoa(i))
  2959. if ids.Id != "" {
  2960. idString += "," + ids.Id
  2961. } else {
  2962. break
  2963. }
  2964. }
  2965. //certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1)
  2966. //certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2)
  2967. var needList []supplierfile.FileList
  2968. var needList1 []supplierfile.FileList
  2969. if cert.SupplierTypeCode == "01" {
  2970. //需要的资质
  2971. total := certsubService.GetCountIsManufacturer(strconv.Itoa(cert.Id))
  2972. if file.Type == 2 && total > 0 {
  2973. errinfo.Message = "非制造商准入范围不能为制造商,请手动修改!"
  2974. errinfo.Code = 0
  2975. this.Data["json"] = &errinfo
  2976. this.ServeJSON()
  2977. return
  2978. }
  2979. gradeTotal := certsubService.GetCountGrade(strconv.Itoa(cert.Id))
  2980. if file.Grade == "2" && gradeTotal > 0 {
  2981. errinfo.Message = "二级供应商不能准入一级物资!"
  2982. errinfo.Code = 0
  2983. this.Data["json"] = &errinfo
  2984. this.ServeJSON()
  2985. return
  2986. }
  2987. needList = filesvc.GetGoodsNeedFileListNew(idString, "2")
  2988. if file.Type == 1 { //制造商
  2989. idString = ""
  2990. for i := 0; i < len(certSubList); i = i + 1000 {
  2991. var ids suppliercertsub.Ids
  2992. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1, strconv.Itoa(i))
  2993. if ids.Id != "" {
  2994. idString += "," + ids.Id
  2995. } else {
  2996. break
  2997. }
  2998. }
  2999. for i := 0; i < len(certSubList); i = i + 1000 {
  3000. var ids1 suppliercertsub.Ids
  3001. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2, strconv.Itoa(i))
  3002. if ids1.Id != "" {
  3003. idString1 += "," + ids1.Id
  3004. } else {
  3005. break
  3006. }
  3007. }
  3008. needList = filesvc.GetGoodsNeedFileListNew(idString, "1")
  3009. needList1 = filesvc.GetGoodsNeedFileListNew(idString1, "2")
  3010. var needFile supplierfile.FileList
  3011. // 质量管理体系认证证书
  3012. CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
  3013. needFile.FileName = CNPCrenkezhengshu
  3014. needList = append(needList, needFile)
  3015. for _, need := range needList1 {
  3016. needList = append(needList, need)
  3017. }
  3018. }
  3019. } else if cert.SupplierTypeCode == "02" {
  3020. needList = filesvc.GetBasicNeedFileListNew(idString)
  3021. } else if cert.SupplierTypeCode == "03" {
  3022. needList = filesvc.GetTechNeedFileListNew(idString)
  3023. }
  3024. //2021-02-04企管法规处去掉这一限制
  3025. //if cert.InStyle == "4" {
  3026. // var needFile supplierfile.FileList
  3027. // //战略合作协议扫描件
  3028. // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
  3029. // needList = append(needList, needFile)
  3030. //}
  3031. if cert.InStyle == "6" {
  3032. var needFile supplierfile.FileList
  3033. //招标准入需提供招标中标结果
  3034. needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "TheTender")
  3035. needList = append(needList, needFile)
  3036. }
  3037. for _, needHeader := range needList {
  3038. if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
  3039. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  3040. //三证合一或五证合一的证件,不需要验证了
  3041. continue
  3042. }
  3043. var fileist1 supplierfile.OilSupplierFile
  3044. where1 := " SupplierId = '" + strconv.Itoa(file.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
  3045. filesvc.GetEntityByWhere("OilSupplierFile", where1, &fileist1)
  3046. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  3047. errinfo.Message = "请上传!" + needHeader.FileName + "! 详情请点击检查资质按钮查看!"
  3048. errinfo.Code = 0
  3049. this.Data["json"] = &errinfo
  3050. this.ServeJSON()
  3051. return
  3052. } else {
  3053. if file.Table == 3 {
  3054. var filelist2 annualaudit.OilAnnualChangeDetail
  3055. where2 := " SupplierId = '" + strconv.Itoa(file.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
  3056. svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  3057. svc2.GetEntityByWhere("OilAnnualChangeDetail", where2, &filelist2)
  3058. if filelist2.FileName == "" && fileist1.FileName == "" {
  3059. //缺少的资质
  3060. errinfo.Message = "请上传!" + needHeader.FileName + "! 详情请点击检查资质按钮查看!"
  3061. errinfo.Code = 0
  3062. this.Data["json"] = &errinfo
  3063. this.ServeJSON()
  3064. return
  3065. }
  3066. }
  3067. if file.Table == 4 {
  3068. var filelist2 suppliercertappendsub.OilAppendChangeDetail
  3069. where2 := " SupplierId = '" + strconv.Itoa(file.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
  3070. svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
  3071. svc2.GetEntityByWhere("OilAppendChangeDetail", where2, &filelist2)
  3072. if filelist2.FileName == "" && fileist1.FileName == "" {
  3073. //缺少的资质
  3074. errinfo.Message = "请上传!" + needHeader.FileName + "! 详情请点击检查资质按钮查看!"
  3075. errinfo.Code = 0
  3076. this.Data["json"] = &errinfo
  3077. this.ServeJSON()
  3078. return
  3079. }
  3080. }
  3081. }
  3082. }
  3083. errinfo.Code = 1
  3084. this.Data["json"] = &errinfo
  3085. this.ServeJSON()
  3086. }
  3087. // @Title 检查缺资质
  3088. // @Description
  3089. // @Success 200 {object} controllers.Request
  3090. // @router /checkSupplierFileDelete [post]
  3091. func (this *OilSupplierController) CheckSupplierFileDelete() {
  3092. //获取主表信息
  3093. var supplierList []supplier.OilSupplier
  3094. var errinfo ErrorDataInfo
  3095. supplierService := supplier.GetOilSupplierService(utils.DBE)
  3096. supplierService.GetEntitysByWhere(OilSupplierName, "1=1", &supplierList)
  3097. //var total int64
  3098. //var total1 int64
  3099. for _, supplier := range supplierList {
  3100. var supplierCertEntity []suppliercert.OilSupplierCert
  3101. supplierService.GetEntitysByWhere("OilSupplierCert", "SupplierId = "+strconv.Itoa(supplier.Id), &supplierCertEntity)
  3102. for _, cert := range supplierCertEntity {
  3103. where2 := "("
  3104. where3 := "("
  3105. //对准入范围的判断
  3106. var certSubList []suppliercertsub.OilSupplierCertSub
  3107. certsubService := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  3108. certsubService.GetListByCertId(strconv.Itoa(cert.Id), &certSubList)
  3109. // 查询出已有哪些资质
  3110. var tableheaderList []qualchange.OilQualChangeDetail1
  3111. fileSql := "SELECT * from OilSupplierFile WHERE SupplierId = " + strconv.Itoa(supplier.Id)
  3112. svcHeader := tableheader.GetTableHeaderService(utils.DBE)
  3113. svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
  3114. var companyHasHeaders string
  3115. for _, tableheader := range tableheaderList {
  3116. companyHasHeaders += tableheader.NeedFileType + ","
  3117. }
  3118. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  3119. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  3120. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  3121. idString := ""
  3122. idString1 := ""
  3123. for i := 0; i < len(certSubList); i = i + 1000 {
  3124. var ids suppliercertsub.Ids
  3125. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 3, strconv.Itoa(i))
  3126. if ids.Id != "" {
  3127. idString += "," + ids.Id
  3128. } else {
  3129. break
  3130. }
  3131. }
  3132. var needList []supplierfile.FileList
  3133. var needList1 []supplierfile.FileList
  3134. if cert.SupplierTypeCode == "01" {
  3135. //需要的资质
  3136. needList1 = filesvc.GetGoodsNeedFileListNew(idString, "2")
  3137. if supplier.OperType == "制造商" { //制造商
  3138. //如果是制造商,准入范围按照各项准入范围的类型判断
  3139. // 制造
  3140. idString = ""
  3141. for i := 0; i < len(certSubList); i = i + 1000 {
  3142. var ids suppliercertsub.Ids
  3143. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1, strconv.Itoa(i))
  3144. if ids.Id != "" {
  3145. idString += "," + ids.Id
  3146. } else {
  3147. break
  3148. }
  3149. }
  3150. // 非制造
  3151. for i := 0; i < len(certSubList); i = i + 1000 {
  3152. var ids1 suppliercertsub.Ids
  3153. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2, strconv.Itoa(i))
  3154. if ids1.Id != "" {
  3155. idString1 += "," + ids1.Id
  3156. } else {
  3157. break
  3158. }
  3159. }
  3160. needList = filesvc.GetGoodsNeedFileListNew(idString, "1")
  3161. needList1 = filesvc.GetGoodsNeedFileListNew(idString1, "2")
  3162. //for _, need := range needList1 {
  3163. // needList = append(needList, need)
  3164. //}
  3165. }
  3166. } else if cert.SupplierTypeCode == "02" {
  3167. needList = filesvc.GetBasicNeedFileListNew(idString)
  3168. } else if cert.SupplierTypeCode == "03" {
  3169. needList = filesvc.GetTechNeedFileListNew(idString)
  3170. }
  3171. needName := ""
  3172. for _, needHeader := range needList {
  3173. if (supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2") &&
  3174. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  3175. //三证合一或五证合一的证件,不需要验证了
  3176. continue
  3177. }
  3178. if cert.SupplierTypeCode == "02" && (needHeader.FileName == "安全资质审查" || needHeader.FileName == "培训考核") {
  3179. // 基建类
  3180. continue
  3181. }
  3182. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  3183. var header tableheader.BaseTableheader
  3184. where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
  3185. if cert.SupplierTypeCode == "01" {
  3186. where1 += " and IsManuf != '2'"
  3187. }
  3188. supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
  3189. if header.Code != "" {
  3190. needName += header.Name + ","
  3191. if where2 == "(" {
  3192. where2 += header.Code + " = '1'"
  3193. } else {
  3194. where2 += " or " + header.Code + " = '1'"
  3195. }
  3196. } else {
  3197. fmt.Print("22222")
  3198. }
  3199. }
  3200. }
  3201. for _, needHeader := range needList1 {
  3202. if (supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2") &&
  3203. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  3204. //三证合一或五证合一的证件,不需要验证了
  3205. continue
  3206. }
  3207. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  3208. var header tableheader.BaseTableheader
  3209. where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
  3210. if cert.SupplierTypeCode == "01" {
  3211. // 非制造商
  3212. where1 += " and IsManuf != '1'"
  3213. }
  3214. supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
  3215. if header.Code != "" {
  3216. needName += header.Name + ","
  3217. if where3 == "(" {
  3218. where3 += header.Code + " = '1'"
  3219. } else {
  3220. where3 += " or " + header.Code + " = '1'"
  3221. }
  3222. } else {
  3223. fmt.Print("11111")
  3224. }
  3225. }
  3226. }
  3227. if where2 == "(" && where3 == "(" {
  3228. continue
  3229. }
  3230. if cert.SupplierTypeCode != "01" && where2 == "(" {
  3231. continue
  3232. }
  3233. where2 += ") and a.SupplierId = " + strconv.Itoa(supplier.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
  3234. where3 += ") and a.SupplierId = " + strconv.Itoa(supplier.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
  3235. var certSub []suppliercertsub.OilSupplierCertSub
  3236. if cert.SupplierTypeCode == "01" {
  3237. if supplier.OperType == "制造商" {
  3238. where2 += " and IsManufacturer != 2"
  3239. where3 += " and IsManufacturer = 2"
  3240. supplierService.GetDeleteSub(OilGoodsAptitudeName, where2, &certSub)
  3241. supplierService.GetDeleteSub(OilGoodsAptitudeName, where3, &certSub)
  3242. } else {
  3243. supplierService.GetDeleteSub(OilGoodsAptitudeName, where3, &certSub)
  3244. }
  3245. } else if cert.SupplierTypeCode == "02" {
  3246. supplierService.GetDeleteSub(OilBasisBuildName, where2, &certSub)
  3247. } else {
  3248. supplierService.GetDeleteSub(OilTechnologyServiceName, where2, &certSub)
  3249. }
  3250. var supplierCert suppliercert.OilSupplierCert
  3251. supplierCert.BackRemark = needName
  3252. cols := []string{"BackRemark"}
  3253. supplierService.UpdateEntityBywheretbl(OilSupplierCertName, &supplierCert, cols, "Id = "+strconv.Itoa(cert.Id))
  3254. }
  3255. }
  3256. errinfo.Code = 1
  3257. this.Data["json"] = &errinfo
  3258. this.ServeJSON()
  3259. }
  3260. // @Title 检查缺资质列表
  3261. // @Description
  3262. // @Success 200 {object} controllers.Request
  3263. // @router /checkSupplierFileList [post]
  3264. func (this *OilSupplierController) CheckSupplierFileList() {
  3265. var file supplierfile.CheckFile
  3266. var jsonBlob = this.Ctx.Input.RequestBody
  3267. json.Unmarshal(jsonBlob, &file)
  3268. //获取主表信息
  3269. var supplierEntity supplier.OilSupplier
  3270. supplierService := supplier.GetOilSupplierService(utils.DBE)
  3271. supplierService.GetEntityById(file.SupplierId, &supplierEntity)
  3272. //获取准入信息表
  3273. var certList []suppliercert.OilSupplierCert
  3274. supplierService.GetEntitysByWhere("OilSupplierCert", "SupplierId = "+strconv.Itoa(file.SupplierId), &certList)
  3275. certsubService := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
  3276. // 查询出已有哪些资质
  3277. var tableheaderList []qualchange.OilQualChangeDetail1
  3278. //whereInfoFile := ""
  3279. //if file.CertId == "0" {
  3280. // // 信息变更 不获取 增项和年审审核中的数据
  3281. // whereInfoFile = " and SupType in (0,1,3,4,5)"
  3282. //} else {
  3283. // whereInfoFile = " and SupType in (0,1,2,3,5)"
  3284. //}
  3285. fileSql := "SELECT * from OilSupplierFile WHERE SupplierId = " + strconv.Itoa(file.SupplierId)
  3286. svcHeader := tableheader.GetTableHeaderService(utils.DBE)
  3287. svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
  3288. var companyHasHeaders string
  3289. for _, tableheader := range tableheaderList {
  3290. companyHasHeaders += tableheader.NeedFileType + ","
  3291. }
  3292. paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
  3293. filesvc := supplierfile.GetSupplierfileService(utils.DBE)
  3294. mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
  3295. for _, cert := range certList {
  3296. if file.CertId != "0" && strconv.Itoa(cert.Id) != file.CertId {
  3297. continue
  3298. }
  3299. whereInfo := ""
  3300. if file.CertId == "0" {
  3301. // 信息变更 不获取 增项审核中的数据
  3302. whereInfo = " and Type != '2'"
  3303. }
  3304. var certSubList2 suppliercertsub.OilSupplierCertSub
  3305. certSubList2.LackFile = ""
  3306. certSubList2.IsQuestion = 0
  3307. svcHeader.UpdateEntityBywheretbl(OilSupplierCertSubName, &certSubList2, []string{"LackFile", "IsQuestion"}, "IsQuestion = 2 and SupplierId = "+strconv.Itoa(supplierEntity.Id)+" and SupplierCertId = "+strconv.Itoa(cert.Id)+whereInfo)
  3308. //对准入范围的判断
  3309. var certSubList []suppliercertsub.OilSupplierCertSub
  3310. certsubService.GetListByCertId(strconv.Itoa(cert.Id), &certSubList)
  3311. certsubService.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = "+strconv.Itoa(cert.Id)+whereInfo, &certSubList)
  3312. idString := ""
  3313. idString1 := ""
  3314. for i := 0; i < len(certSubList); i = i + 1000 {
  3315. var ids suppliercertsub.Ids
  3316. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 3, strconv.Itoa(i))
  3317. if ids.Id != "" {
  3318. idString += "," + ids.Id
  3319. } else {
  3320. break
  3321. }
  3322. }
  3323. var needList []supplierfile.FileList
  3324. var needList1 []supplierfile.FileList
  3325. if cert.SupplierTypeCode == "01" {
  3326. //需要的资质
  3327. needList1 = filesvc.GetGoodsNeedFileListNew(idString, "2")
  3328. if file.Type == 1 { //制造商
  3329. //如果是制造商,准入范围按照各项准入范围的类型判断
  3330. // 制造
  3331. idString = ""
  3332. for i := 0; i < len(certSubList); i = i + 1000 {
  3333. var ids suppliercertsub.Ids
  3334. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1, strconv.Itoa(i))
  3335. if ids.Id != "" {
  3336. idString += "," + ids.Id
  3337. } else {
  3338. break
  3339. }
  3340. }
  3341. // 非制造
  3342. for i := 0; i < len(certSubList); i = i + 1000 {
  3343. var ids1 suppliercertsub.Ids
  3344. certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2, strconv.Itoa(i))
  3345. if ids1.Id != "" {
  3346. idString1 += "," + ids1.Id
  3347. } else {
  3348. break
  3349. }
  3350. }
  3351. needList = filesvc.GetGoodsNeedFileListNew(idString, "1")
  3352. needList1 = filesvc.GetGoodsNeedFileListNew(idString1, "2")
  3353. }
  3354. } else if cert.SupplierTypeCode == "02" {
  3355. needList = filesvc.GetBasicNeedFileListNew(idString)
  3356. } else if cert.SupplierTypeCode == "03" {
  3357. needList = filesvc.GetTechNeedFileListNew(idString)
  3358. }
  3359. for _, needHeader := range needList {
  3360. if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
  3361. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  3362. //三证合一或五证合一的证件,不需要验证了
  3363. continue
  3364. }
  3365. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  3366. var header tableheader.BaseTableheader
  3367. where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
  3368. if cert.SupplierTypeCode == "01" {
  3369. where1 += " and IsManuf != '2'"
  3370. }
  3371. supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
  3372. if header.Code != "" {
  3373. where2 := header.Code + " = '1'"
  3374. where2 += " and a.SupplierId = " + strconv.Itoa(supplierEntity.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
  3375. var certSub []suppliercertsub.OilSupplierCertSub
  3376. if cert.SupplierTypeCode == "01" {
  3377. where2 += " and IsManufacturer != 2"
  3378. supplierService.GetDeleteSub2(OilGoodsAptitudeName, where2, &certSub, header.Name)
  3379. } else if cert.SupplierTypeCode == "02" {
  3380. supplierService.GetDeleteSub2(OilBasisBuildName, where2, &certSub, header.Name)
  3381. } else {
  3382. supplierService.GetDeleteSub2(OilTechnologyServiceName, where2, &certSub, header.Name)
  3383. }
  3384. } else {
  3385. fmt.Print("22222")
  3386. }
  3387. }
  3388. }
  3389. for _, needHeader := range needList1 {
  3390. // 非制造
  3391. if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
  3392. strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
  3393. //三证合一或五证合一的证件,不需要验证了
  3394. continue
  3395. }
  3396. if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
  3397. var header tableheader.BaseTableheader
  3398. where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
  3399. if cert.SupplierTypeCode == "01" {
  3400. where1 += " and IsManuf != '1'"
  3401. }
  3402. supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
  3403. if header.Code != "" {
  3404. where2 := header.Code + " = '1'"
  3405. where2 += " and a.SupplierId = " + strconv.Itoa(supplierEntity.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
  3406. var certSub []suppliercertsub.OilSupplierCertSub
  3407. if file.Type == 1 {
  3408. where2 += " and IsManufacturer = 2"
  3409. }
  3410. supplierService.GetDeleteSub2(OilGoodsAptitudeName, where2, &certSub, header.Name)
  3411. } else {
  3412. fmt.Print("22222")
  3413. }
  3414. }
  3415. }
  3416. }
  3417. var certSubList1 []suppliercertsub.OilSupplierCertSub
  3418. var total int64
  3419. where3 := "IsQuestion = 2 and SupplierId = " + strconv.Itoa(supplierEntity.Id)
  3420. if file.FileName != "" {
  3421. where3 += " and LackFile like '%" + file.FileName + "%'"
  3422. }
  3423. if file.SubName != "" {
  3424. where3 += " and Name like '%" + file.SubName + "%'"
  3425. }
  3426. if file.CertId != "0" {
  3427. where3 += " and SupplierCertId = " + file.CertId
  3428. }
  3429. total = certsubService.GetPagingEntitiesWithOrderBytbl("", file.CurrentPage, file.Size, "Id", true, &certSubList1, where3)
  3430. var datainfo DataInfo
  3431. datainfo.CurrentItemCount = total
  3432. datainfo.PageIndex = file.CurrentPage
  3433. datainfo.ItemsPerPage = file.Size
  3434. datainfo.Items = certSubList1
  3435. this.Data["json"] = &datainfo
  3436. this.ServeJSON()
  3437. }
  3438. // @Title 对外-招投标系统
  3439. // @Description
  3440. // @Success 200 {object}
  3441. // @router /getSupplierList [post]
  3442. func (this *OilSupplierController) GetSupplierList() {
  3443. //获取分页信息
  3444. CurrentPage, _ := this.GetInt64("pageIndex", 1)
  3445. Size, _ := this.GetInt64("pageSize", 10)
  3446. where := " b.InFlag = 1 "
  3447. orderby := "Id"
  3448. asc := false
  3449. Order := this.GetString("Order")
  3450. Prop := this.GetString("Prop")
  3451. if Order != "" && Prop != "" {
  3452. orderby = Prop
  3453. if Order == "asc" {
  3454. asc = true
  3455. }
  3456. }
  3457. SupplierName := this.GetString("Keyword")
  3458. SupplierTypeName := this.GetString("SupplierTypeName")
  3459. SupplierTypeCode := this.GetString("accessCategoryCode")
  3460. if SupplierName != "" {
  3461. where = where + " and a.SupplierName like '%" + SupplierName + "%'"
  3462. }
  3463. if SupplierTypeName != "" {
  3464. where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
  3465. }
  3466. if SupplierTypeCode != "" {
  3467. where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
  3468. }
  3469. svc := supplier.GetOilSupplierService(utils.DBE)
  3470. var total int64
  3471. var list []supplier.CompanyList
  3472. total = svc.GetMyPagingEntitiesWithOrderBytbl4(OilSupplierName, OilSupplierCertName, CurrentPage, Size, orderby, asc, &list, where)
  3473. var datainfo DataInfo
  3474. datainfo.Items = list
  3475. datainfo.CurrentItemCount = total
  3476. datainfo.PageIndex = CurrentPage
  3477. datainfo.ItemsPerPage = Size
  3478. this.Data["json"] = &datainfo
  3479. this.ServeJSON()
  3480. }
  3481. // @Title 根据supplierId查certId
  3482. // @Description
  3483. // @Success 200 {object}
  3484. // @router /getSupplierCertId/:Id [get]
  3485. func (this *OilSupplierController) GetSupplierCertId() {
  3486. Id := this.Ctx.Input.Param(":Id")
  3487. var certList []suppliercert.OilSupplierCert
  3488. svc := supplier.GetOilSupplierService(utils.DBE)
  3489. svc.GetEntitysByWhere(OilSupplierCertName, "SupplierId = "+Id, &certList)
  3490. var datainfo DataInfo
  3491. datainfo.Items = certList
  3492. this.Data["json"] = &datainfo
  3493. this.ServeJSON()
  3494. }