supplier.go 108 KB

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