2
3

supplier.go 90 KB

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