select.go 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601
  1. package oilsupplier
  2. import (
  3. "archive/zip"
  4. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  5. "encoding/json"
  6. "fmt"
  7. "github.com/tealeg/xlsx"
  8. "io"
  9. "log"
  10. "os"
  11. "sort"
  12. "strconv"
  13. "strings"
  14. "time"
  15. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  16. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  17. "dashoo.cn/backend/api/business/oilsupplier/qualchange"
  18. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  19. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  20. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  21. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  22. "dashoo.cn/backend/api/business/register"
  23. // "fmt"
  24. "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
  25. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  26. . "dashoo.cn/backend/api/controllers"
  27. "dashoo.cn/utils"
  28. . "github.com/linxGnu/goseaweedfs"
  29. )
  30. type SelectController struct {
  31. BaseController
  32. }
  33. type UpSearch struct {
  34. FullName string
  35. }
  36. type UpInfoSearch struct {
  37. FullName string
  38. SupplierTypeName string
  39. HeGe int
  40. BuHeGe int
  41. ZongShu int
  42. Reason string
  43. }
  44. type Processinfo struct {
  45. Id int
  46. SupplierId int
  47. AccessCardNo string
  48. WorkflowId string
  49. ProcessKey string
  50. SupplierName string
  51. SupplierTypeCode string
  52. Status string
  53. Type string
  54. CreateOn time.Time
  55. AddinTime time.Time
  56. RecUnitName string
  57. ContactName string
  58. Mobile string
  59. }
  60. // @Title 获取所有
  61. // @Description
  62. // @Success 200 {object}
  63. // @router /getcompanylist [post]
  64. func (this *SelectController) GetTList() {
  65. var model supplier.OilSupplierSelect
  66. var model1 supplier.RegCapitalRange //注册资金范围
  67. //var model2 supplier.NeedFileTypeStruct //资质结构体
  68. var jsonBlob = this.Ctx.Input.RequestBody
  69. json.Unmarshal(jsonBlob, &model)
  70. json.Unmarshal(jsonBlob, &model1)
  71. //json.Unmarshal(jsonBlob, &model2)
  72. // //获取分页信息
  73. page := this.GetPageInfoForm()
  74. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' "
  75. orderby := "a.Id"
  76. asc := true
  77. Order := this.GetString("Order")
  78. Prop := this.GetString("Prop")
  79. OperType := this.GetString("OperType")
  80. Grade := this.GetString("Grade")
  81. CheckUId := this.GetString("CheckUId")
  82. FullId := this.GetString("FullId")
  83. if Order != "" && Prop != "" {
  84. orderby = Prop
  85. if Order == "desc" {
  86. asc = false
  87. }
  88. }
  89. //准入证号
  90. if model.AccessCardNo != "" {
  91. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  92. }
  93. //企业名称
  94. if model.SupplierName != "" {
  95. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  96. }
  97. if model.OldSupplierName != "" {
  98. where = where + " and a.OldSupplierName like '%" + model.OldSupplierName + "%'"
  99. }
  100. if FullId != "" {
  101. where = where + " and f.Id = '" + FullId + "'"
  102. }
  103. if CheckUId != "" {
  104. where = where + " and b.RecUnitId = '" + CheckUId + "'"
  105. }
  106. //准入类别(基建,物资,技术服务)
  107. if model.SupplierTypeCode != "" {
  108. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  109. }
  110. //准入标识 1 准入 2 暂停 3取消
  111. if model.InFlag != "" {
  112. where = where + " and b.InFlag = '" + model.InFlag + "'"
  113. }
  114. //法人
  115. if model.LegalPerson != "" {
  116. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  117. }
  118. //联系人
  119. if model.ContactName != "" {
  120. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  121. }
  122. //统一社会信用代码
  123. if model.CommercialNo != "" {
  124. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  125. }
  126. //开户银行
  127. if model.DepositBank != "" {
  128. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  129. }
  130. if OperType == "1" {
  131. OperType = "制造商"
  132. } else if OperType == "2" {
  133. OperType = "代理商"
  134. } else if OperType == "3" {
  135. OperType = "贸易商"
  136. }
  137. //准入状态
  138. if OperType != "" {
  139. where = where + " and a.OperType = '" + OperType + "'"
  140. }
  141. //级别
  142. if Grade != "" {
  143. where = where + " and a.Grade = '" + Grade + "'"
  144. }
  145. //HSE审查
  146. if model.HseTraining != "" {
  147. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  148. }
  149. //公司类型
  150. if model.CompanyType != "" {
  151. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  152. }
  153. //成立时间
  154. SetupTime := this.GetString("SetupTime")
  155. if SetupTime != "" {
  156. where = where + " and a.SetupTime ='" + SetupTime + "'"
  157. }
  158. //注册资金范围
  159. if model1.RegCapital1 != "" {
  160. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  161. }
  162. if model1.RegCapital2 != "" {
  163. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  164. }
  165. //注册省份
  166. if model.Province != "" {
  167. where = where + " and a.Province = '" + model.Province + "'"
  168. }
  169. //注册市
  170. if model.City != "" {
  171. where = where + " and a.City = '" + model.City + "'"
  172. }
  173. //注册区
  174. if model.Street != "" {
  175. where = where + " and a.Street = '" + model.Street + "'"
  176. }
  177. //注册详细地址
  178. if model.Address != "" {
  179. where = where + " and a.Address like '%" + model.Address + "%'"
  180. }
  181. if model.LinkProvince != "" {
  182. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  183. }
  184. if model.LinkCity != "" {
  185. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  186. }
  187. if model.LinkStreet != "" {
  188. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  189. }
  190. if model.LinkAddress != "" {
  191. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  192. }
  193. //营业范围
  194. if model.BusinessScope != "" {
  195. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  196. }
  197. CreateOn := this.GetString("CreateOn")
  198. if CreateOn != "" {
  199. dates := strings.Split(CreateOn, ",")
  200. if len(dates) == 2 {
  201. minDate := dates[0]
  202. maxDate := dates[1]
  203. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  204. }
  205. }
  206. a := model.InStyle
  207. fmt.Println(a)
  208. //准入方式
  209. if model.InStyle != "" {
  210. if model.InStyle == "0" {
  211. where = where + " and b.InStyle in ('2','3','4','5')"
  212. } else {
  213. where = where + " and b.InStyle ='" + model.InStyle + "'"
  214. }
  215. }
  216. //包含资质
  217. //if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 {
  218. // pararm := ""
  219. // for i := 0; i < len(model2.NeedFileType); i++ {
  220. //
  221. // pararm = pararm + "'" + model2.NeedFileType[i] + "',"
  222. //
  223. // }
  224. // fmt.Println(pararm[0 : len(pararm)-1])
  225. // where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")"
  226. //}
  227. having := ""
  228. CerSubName := strings.Split(model.CerSubName, ",")
  229. comma := strings.Contains(model.CerSubName, ",")
  230. if comma {
  231. CerSubName = strings.Split(model.CerSubName, ",")
  232. } else {
  233. CerSubName = strings.Split(model.CerSubName, ",")
  234. }
  235. var Ids supplier.OilCertIds
  236. //准入范围
  237. if model.CerSubName != "" {
  238. svc := supplier.GetOilSupplierService(utils.DBE)
  239. where1 := ""
  240. for key, value := range CerSubName {
  241. if key == 0 {
  242. where1 += " (Name like '%" + value + "%' or Code like '" + value + "%' "
  243. } else {
  244. where1 += "or Name like '%" + value + "%' or Code like '" + value + "%' "
  245. }
  246. }
  247. where1 += ") "
  248. svc.GetCertIds(&Ids, where1)
  249. }
  250. //资质
  251. if model.NeedFileType != "" {
  252. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  253. }
  254. svc := selectbusiness.GetSelectService(utils.DBE)
  255. var list []supplier.OilSupplierSelect
  256. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  257. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids, model.NeedFileType)
  258. var datainfo DataInfo
  259. datainfo.Items = list
  260. datainfo.CurrentItemCount = total
  261. datainfo.PageIndex = page.CurrentPage
  262. datainfo.ItemsPerPage = page.Size
  263. this.Data["json"] = &datainfo
  264. this.ServeJSON()
  265. }
  266. // @Title get 导出供方信息表
  267. // @Description
  268. // @Success 200 {object}
  269. // @router /export-company-list [post]
  270. func (this *SelectController) ExportCompanyList() {
  271. var model supplier.OilSupplierSelect
  272. var model1 supplier.RegCapitalRange //注册资金范围
  273. var jsonBlob = this.Ctx.Input.RequestBody
  274. json.Unmarshal(jsonBlob, &model)
  275. json.Unmarshal(jsonBlob, &model1)
  276. //json.Unmarshal(jsonBlob, &model2)
  277. // //获取分页信息
  278. page := this.GetPageInfoForm()
  279. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' "
  280. orderby := "a.Id"
  281. asc := true
  282. Order := this.GetString("Order")
  283. Prop := this.GetString("Prop")
  284. OperType := this.GetString("OperType")
  285. Grade := this.GetString("Grade")
  286. CheckUId := this.GetString("CheckUId")
  287. FullId := this.GetString("FullId")
  288. selectedCertIdList := this.GetString("selectedCertIdList")
  289. if Order != "" && Prop != "" {
  290. orderby = Prop
  291. if Order == "desc" {
  292. asc = false
  293. }
  294. }
  295. having := ""
  296. var Ids supplier.OilCertIds
  297. if selectedCertIdList != "" {
  298. where = where + " and b.Id in (" + selectedCertIdList + ") "
  299. } else {
  300. //准入证号
  301. if model.AccessCardNo != "" {
  302. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  303. }
  304. //企业名称
  305. if model.SupplierName != "" {
  306. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  307. }
  308. if model.OldSupplierName != "" {
  309. where = where + " and a.OldSupplierName like '%" + model.OldSupplierName + "%'"
  310. }
  311. if FullId != "" {
  312. where = where + " and f.Id = '" + FullId + "'"
  313. }
  314. if CheckUId != "" {
  315. where = where + " and b.RecUnitId = '" + CheckUId + "'"
  316. }
  317. //准入类别(基建,物资,技术服务)
  318. if model.SupplierTypeCode != "" {
  319. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  320. }
  321. //准入标识 1 准入 2 暂停 3取消
  322. if model.InFlag != "" {
  323. where = where + " and b.InFlag = '" + model.InFlag + "'"
  324. }
  325. //法人
  326. if model.LegalPerson != "" {
  327. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  328. }
  329. //联系人
  330. if model.ContactName != "" {
  331. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  332. }
  333. //统一社会信用代码
  334. if model.CommercialNo != "" {
  335. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  336. }
  337. //开户银行
  338. if model.DepositBank != "" {
  339. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  340. }
  341. if OperType == "1" {
  342. OperType = "制造商"
  343. } else if OperType == "2" {
  344. OperType = "代理商"
  345. } else if OperType == "3" {
  346. OperType = "贸易商"
  347. }
  348. //准入状态
  349. if OperType != "" {
  350. where = where + " and a.OperType = '" + OperType + "'"
  351. }
  352. //级别
  353. if Grade != "" {
  354. where = where + " and a.Grade = '" + Grade + "'"
  355. }
  356. //HSE审查
  357. if model.HseTraining != "" {
  358. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  359. }
  360. //公司类型
  361. if model.CompanyType != "" {
  362. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  363. }
  364. //成立时间
  365. SetupTime := this.GetString("SetupTime")
  366. if SetupTime != "" {
  367. where = where + " and a.SetupTime ='" + SetupTime + "'"
  368. }
  369. //注册资金范围
  370. if model1.RegCapital1 != "" {
  371. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  372. }
  373. if model1.RegCapital2 != "" {
  374. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  375. }
  376. //注册省份
  377. if model.Province != "" {
  378. where = where + " and a.Province = '" + model.Province + "'"
  379. }
  380. //注册市
  381. if model.City != "" {
  382. where = where + " and a.City = '" + model.City + "'"
  383. }
  384. //注册区
  385. if model.Street != "" {
  386. where = where + " and a.Street = '" + model.Street + "'"
  387. }
  388. //注册详细地址
  389. if model.Address != "" {
  390. where = where + " and a.Address like '%" + model.Address + "%'"
  391. }
  392. if model.LinkProvince != "" {
  393. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  394. }
  395. if model.LinkCity != "" {
  396. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  397. }
  398. if model.LinkStreet != "" {
  399. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  400. }
  401. if model.LinkAddress != "" {
  402. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  403. }
  404. //营业范围
  405. if model.BusinessScope != "" {
  406. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  407. }
  408. CreateOn := this.GetString("CreateOn")
  409. if CreateOn != "" {
  410. dates := strings.Split(CreateOn, ",")
  411. if len(dates) == 2 {
  412. minDate := dates[0]
  413. maxDate := dates[1]
  414. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  415. }
  416. }
  417. a := model.InStyle
  418. fmt.Println(a)
  419. //准入方式
  420. if model.InStyle != "" {
  421. if model.InStyle == "0" {
  422. where = where + " and b.InStyle in ('2','3','4','5')"
  423. } else {
  424. where = where + " and b.InStyle ='" + model.InStyle + "'"
  425. }
  426. }
  427. CerSubName := strings.Split(model.CerSubName, ",")
  428. comma := strings.Contains(model.CerSubName, ",")
  429. if comma {
  430. CerSubName = strings.Split(model.CerSubName, ",")
  431. } else {
  432. CerSubName = strings.Split(model.CerSubName, ",")
  433. }
  434. //准入范围
  435. if model.CerSubName != "" {
  436. svc := supplier.GetOilSupplierService(utils.DBE)
  437. where1 := ""
  438. for key, value := range CerSubName {
  439. if key == 0 {
  440. where1 += " (Name like '%" + value + "%' or Code like '" + value + "%' "
  441. } else {
  442. where1 += "or Name like '%" + value + "%' or Code like '" + value + "%' "
  443. }
  444. }
  445. where1 += ") "
  446. svc.GetCertIds(&Ids, where1)
  447. }
  448. //资质
  449. if model.NeedFileType != "" {
  450. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  451. }
  452. }
  453. page.Size = 15000
  454. svc := selectbusiness.GetSelectService(utils.DBE)
  455. var list []supplier.OilSupplierSelect
  456. total := svc.GetMyPagingEntitiesWithOrderBytblForExport(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  457. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids, model.NeedFileType)
  458. log.Print("共导出供方信息:", total)
  459. // 获取到所有符合条件的供方信息列表 ↑
  460. fileTitle := "供方信息表"
  461. //自定义显示列
  462. title := strings.Split("企业名称,准入证号,准入类别,准入方式,状态,有效日期,企业曾用名,级别,供应商类型,法人代表,注册资金,联系人,"+
  463. "移动电话,统一社会信用代码,开户银行,公司类型,成立时间,推荐单位,专业处室,申请时间,注册地址,通信地址,营业范围,企业资质,备注", ",")
  464. f := xlsx.NewFile()
  465. sheet, _ := f.AddSheet(fileTitle)
  466. row := sheet.AddRow()
  467. row.WriteSlice(&title, -1)
  468. // 与表头顺序一一对应 ↓
  469. nilTime := time.Time{}
  470. for _, item := range list {
  471. var dataArr []string
  472. dataArr = append(dataArr, item.SupplierName)
  473. dataArr = append(dataArr, item.AccessCardNo)
  474. // 准入类别
  475. if item.SupplierTypeCode == "01" {
  476. dataArr = append(dataArr, "物资类")
  477. } else if item.SupplierTypeCode == "02" {
  478. dataArr = append(dataArr, "基建类")
  479. } else if item.SupplierTypeCode == "03" {
  480. dataArr = append(dataArr, "服务类")
  481. } else {
  482. dataArr = append(dataArr, "")
  483. }
  484. // 准入方式
  485. if item.InStyle == "1" {
  486. dataArr = append(dataArr, "评审准入")
  487. } else if item.InStyle == "2" {
  488. dataArr = append(dataArr, "一级物资备案准入")
  489. } else if item.InStyle == "3" {
  490. dataArr = append(dataArr, "二级物资备案准入")
  491. } else if item.InStyle == "4" {
  492. dataArr = append(dataArr, "战略合作准入")
  493. } else if item.InStyle == "5" {
  494. dataArr = append(dataArr, "内部多元准入")
  495. } else if item.InStyle == "6" {
  496. dataArr = append(dataArr, "招标准入")
  497. } else {
  498. dataArr = append(dataArr, "")
  499. }
  500. // 准入标识
  501. if item.InFlag == "1" {
  502. dataArr = append(dataArr, "准入")
  503. } else if item.InFlag == "2" {
  504. dataArr = append(dataArr, "暂停")
  505. } else if item.InFlag == "3" {
  506. dataArr = append(dataArr, "取消")
  507. } else {
  508. dataArr = append(dataArr, "")
  509. }
  510. if item.ApplyTime == nilTime {
  511. dataArr = append(dataArr, "")
  512. } else {
  513. dataArr = append(dataArr, item.ApplyTime.Format("2006-01-02 15:04:05"))
  514. }
  515. dataArr = append(dataArr, item.OldSupplierName)
  516. if item.Grade == "1" {
  517. dataArr = append(dataArr, "一级")
  518. } else if item.Grade == "2" {
  519. dataArr = append(dataArr, "二级")
  520. } else {
  521. dataArr = append(dataArr, "")
  522. }
  523. if item.OperType == "制造商" {
  524. dataArr = append(dataArr, item.OperType)
  525. } else {
  526. dataArr = append(dataArr, "非制造商")
  527. }
  528. dataArr = append(dataArr, item.LegalPerson)
  529. dataArr = append(dataArr, strconv.FormatFloat(item.RegCapital, 'f', 2, 64))
  530. dataArr = append(dataArr, item.ContactName)
  531. dataArr = append(dataArr, item.Mobile)
  532. dataArr = append(dataArr, item.CommercialNo)
  533. dataArr = append(dataArr, item.DepositBank)
  534. dataArr = append(dataArr, item.CompanyType)
  535. if item.SetupTime == nilTime {
  536. dataArr = append(dataArr, "")
  537. } else {
  538. dataArr = append(dataArr, item.SetupTime.Format("2006-01-02 15:04:05"))
  539. }
  540. dataArr = append(dataArr, item.CheckUnitName)
  541. dataArr = append(dataArr, item.FullName)
  542. if item.CreateOn == nilTime {
  543. dataArr = append(dataArr, "")
  544. } else {
  545. dataArr = append(dataArr, item.CreateOn.Format("2006-01-02 15:04:05"))
  546. }
  547. dataArr = append(dataArr, item.Address)
  548. dataArr = append(dataArr, item.LinkAddress)
  549. dataArr = append(dataArr, item.BusinessScope)
  550. dataArr = append(dataArr, item.NeedFileType)
  551. // dataArr = append(dataArr, item.CerSubName) // 准入编码
  552. dataArr = append(dataArr, item.Remark)
  553. row := sheet.AddRow()
  554. row.WriteSlice(&dataArr, -1)
  555. }
  556. for c, cl := 0, len(sheet.Cols); c < cl; c++ {
  557. sheet.Cols[c].Width = 20
  558. }
  559. dir := "static/file/excel/report/" + this.GetAccode()
  560. SaveDirectory(dir)
  561. path := dir + "/" + "supplier_export_" + utils.TimeFormat(time.Now(), "20060102") + fileTitle + ".xlsx"
  562. f.Save(path)
  563. var sw *Seaweed
  564. var filer []string
  565. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  566. filer = []string{_filer}
  567. }
  568. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  569. _, _, fID, _ := sw.UploadFile(path, "", "")
  570. retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  571. os.Remove(path)
  572. this.Data["json"] = retDocUrl
  573. this.ServeJSON()
  574. }
  575. // @Title 根据公司名获取公司信息和准入
  576. // @Description
  577. // @Success 200 {object}
  578. // @router /getbaseinfo [post]
  579. func (this *SelectController) GetBaseInfo() {
  580. Spesearch := this.GetString("Spesearch")
  581. spesearchs := strings.Split(Spesearch, ",")
  582. svc := selectbusiness.GetSelectService(utils.DBE)
  583. var infoIntelist []supplier.OilSupplierInte
  584. for _, item := range spesearchs {
  585. //var supplierinfo supplier.SupplierInfoInte
  586. var infoInte supplier.OilSupplierInte
  587. where := " where 1 = 1 AND a.SupplierName = '" + item + "'"
  588. svc.GetInfoByCompId(where, &infoInte.SupplierInfo)
  589. var cert1 suppliercert.OilSupplierCert
  590. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'"
  591. svc.GetEntityByWhere(OilSupplierCertName, where, &cert1)
  592. infoInte.SupplierInfo.WZStatus = cert1.InFlag
  593. infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02")
  594. var cert2 suppliercert.OilSupplierCert
  595. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'"
  596. svc.GetEntityByWhere(OilSupplierCertName, where, &cert2)
  597. infoInte.SupplierInfo.JSStatus = cert2.InFlag
  598. infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02")
  599. var cert3 suppliercert.OilSupplierCert
  600. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'"
  601. svc.GetEntityByWhere(OilSupplierCertName, where, &cert3)
  602. infoInte.SupplierInfo.JFStatus = cert3.InFlag
  603. infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02")
  604. if infoInte.SupplierInfo.SupplierName != "" {
  605. //var suplliersup []supplier.OilSupplierCertSubInte
  606. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'"
  607. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  608. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'"
  609. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  610. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'"
  611. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  612. } else if item == "" {
  613. where = "where SupplierTypeCode='01'"
  614. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  615. where = "where and SupplierTypeCode='02'"
  616. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  617. where = "where SupplierTypeCode='03'"
  618. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  619. }
  620. infoIntelist = append(infoIntelist, infoInte)
  621. }
  622. var datainfo DataInfo
  623. datainfo.Items = infoIntelist
  624. this.Data["json"] = &datainfo
  625. this.ServeJSON()
  626. }
  627. // @Title 根据分页获取公司信息和准入, // 提供给银行接口的用户名 和 密码:ceshi1, Ceshi111
  628. // @Description
  629. // @Success 200 {object}
  630. // @router /getinfobypage [post]
  631. func (this *SelectController) GetInfoByPage() {
  632. page := this.GetString("page")
  633. svc := selectbusiness.GetSelectService(utils.DBE)
  634. var infoIntelist []supplier.OilSupplierInte
  635. intpage, _ := strconv.Atoi(page)
  636. for i := (intpage - 1) * 50; i < (intpage * 50); i++ {
  637. //var supplierinfo supplier.SupplierInfoInte
  638. var infoInte supplier.OilSupplierInte
  639. stringi := strconv.Itoa(i)
  640. where := " where 1 = 1 limit " + stringi + ",1"
  641. svc.GetInfoByCompId(where, &infoInte.SupplierInfo)
  642. var cert1 suppliercert.OilSupplierCert
  643. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'"
  644. svc.GetEntityByWhere(OilSupplierCertName, where, &cert1)
  645. infoInte.SupplierInfo.WZStatus = cert1.InFlag
  646. infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02")
  647. var cert2 suppliercert.OilSupplierCert
  648. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'"
  649. svc.GetEntityByWhere(OilSupplierCertName, where, &cert2)
  650. infoInte.SupplierInfo.JSStatus = cert2.InFlag
  651. infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02")
  652. var cert3 suppliercert.OilSupplierCert
  653. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'"
  654. svc.GetEntityByWhere(OilSupplierCertName, where, &cert3)
  655. infoInte.SupplierInfo.JFStatus = cert3.InFlag
  656. infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02")
  657. if infoInte.SupplierInfo.SupplierName != "" {
  658. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'"
  659. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  660. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'"
  661. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  662. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'"
  663. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  664. }
  665. if infoInte.SupplierInfo.Id != 0 {
  666. infoIntelist = append(infoIntelist, infoInte)
  667. }
  668. }
  669. var datainfo DataInfo
  670. datainfo.Items = infoIntelist
  671. this.Data["json"] = &datainfo
  672. this.ServeJSON()
  673. }
  674. // @Title 获取所有
  675. // @Description
  676. // @Success 200 {object}
  677. // @router /up [post]
  678. func (this *SelectController) Up() {
  679. var model UpSearch
  680. var jsonBlob = this.Ctx.Input.RequestBody
  681. json.Unmarshal(jsonBlob, &model)
  682. // //获取分页信息
  683. page := this.GetPageInfoForm()
  684. where := ""
  685. asc := false
  686. Order := this.GetString("Order")
  687. Prop := this.GetString("Prop")
  688. CreateOn := this.GetString("CreateOn")
  689. if Order != "" && Prop != "" {
  690. if Order == "asc" {
  691. asc = true
  692. }
  693. }
  694. if CreateOn != "" {
  695. dates := strings.Split(CreateOn, ",")
  696. if len(dates) == 2 {
  697. minDate := dates[0]
  698. maxDate := dates[1]
  699. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  700. }
  701. }
  702. if model.FullName != "" {
  703. where = where + " and (select FullName from Base_Organize where Id = a.CommitComId) like '%" + model.FullName + "%'"
  704. }
  705. svc := selectbusiness.GetSelectService(utils.DBE)
  706. var list []UpInfoSearch
  707. total := svc.GetUp(OilSupplierCertName, page.CurrentPage, page.Size, Prop, asc, &list, where)
  708. var datainfo DataInfo
  709. datainfo.Items = list
  710. datainfo.CurrentItemCount = total
  711. datainfo.PageIndex = page.CurrentPage
  712. datainfo.ItemsPerPage = page.Size
  713. this.Data["json"] = &datainfo
  714. this.ServeJSON()
  715. }
  716. // @Title 获取所有资质名称
  717. // @Description
  718. // @Success 200 {object}
  719. // @router /getnftoptions [post]
  720. func (this *SelectController) GetNFTOptions() {
  721. svc := selectbusiness.GetSelectService(utils.DBE)
  722. var list []map[string]string
  723. sql := "select distinct(Name) from " + BaseTableHeader + ""
  724. list, _ = svc.DBE.QueryString(sql)
  725. var datainfo DataInfo
  726. datainfo.Items = list
  727. this.Data["json"] = &datainfo
  728. this.ServeJSON()
  729. }
  730. // @Title 流程查询准入
  731. // @Description
  732. // @Success 200 {object}
  733. // @router /getprocessauditlist [get]
  734. func (this *SelectController) GetProcessAuditList() {
  735. //获取分页信息
  736. page := this.GetPageInfoForm()
  737. where := " 1=1 and b.WorkflowId != '' and b.WorkflowId != '0' "
  738. orderby := "Id"
  739. asc := false
  740. Order := this.GetString("Order")
  741. Prop := this.GetString("Prop")
  742. if Order != "" && Prop != "" {
  743. orderby = Prop
  744. if Order == "asc" {
  745. asc = true
  746. }
  747. }
  748. svc := supplier.GetOilSupplierService(utils.DBE)
  749. tabinx := this.GetString("tabinx")
  750. supplierTypeCode := this.GetString("SupplierTypeCode")
  751. supplierName := this.GetString("SupplierName")
  752. CreateOn := this.GetString("CreateOn")
  753. //企业用户必须加创建人条件
  754. var registerUser register.OilCorporateInfo
  755. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  756. svc.GetEntity(&registerUser, sql)
  757. var processinfolist []Processinfo
  758. if this.User.IsCompanyUser == 1 {
  759. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  760. }
  761. if supplierTypeCode != "" {
  762. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  763. }
  764. if supplierName != "" {
  765. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  766. }
  767. var total int64 = 0
  768. var datainfo DataInfo
  769. if tabinx == "1" || tabinx == "0" {
  770. var list []Processinfo //[]supplier.OilSupplierView
  771. if CreateOn != "" {
  772. dates := strings.Split(CreateOn, ",")
  773. if len(dates) == 2 {
  774. minDate := dates[0]
  775. maxDate := dates[1]
  776. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  777. }
  778. }
  779. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, "b.Id", asc, &list, where)
  780. processinfolist = append(processinfolist, list...)
  781. //datainfo.Items = processinfolist
  782. }
  783. if tabinx == "2" || tabinx == "0" {
  784. whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'"
  785. //企业用户必须加创建人条件
  786. if this.User.IsCompanyUser == 1 {
  787. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  788. }
  789. if supplierTypeCode != "" {
  790. whereapp = whereapp + " and a.AppendType = '" + supplierTypeCode + "'"
  791. }
  792. if supplierName != "" {
  793. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  794. }
  795. if CreateOn != "" {
  796. dates := strings.Split(CreateOn, ",")
  797. if len(dates) == 2 {
  798. minDate := dates[0]
  799. maxDate := dates[1]
  800. whereapp = whereapp + " a.and CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  801. }
  802. }
  803. var list []Processinfo //[]suppliercertappend.OilSupplierCertAppend
  804. svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  805. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierCertAppendName, page.CurrentPage, page.Size, "a.Id", asc, &list, whereapp)
  806. processinfolist = append(processinfolist, list...)
  807. //datainfo.Items = processinfolist
  808. }
  809. if tabinx == "3" || tabinx == "0" {
  810. whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'"
  811. //企业用户必须加创建人条件
  812. if this.User.IsCompanyUser == 1 {
  813. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  814. }
  815. if supplierTypeCode != "" {
  816. whereapp = whereapp + " and a.SupplierTypeName = '" + supplierTypeCode + "'"
  817. }
  818. if supplierName != "" {
  819. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  820. }
  821. if CreateOn != "" {
  822. dates := strings.Split(CreateOn, ",")
  823. if len(dates) == 2 {
  824. minDate := dates[0]
  825. maxDate := dates[1]
  826. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  827. }
  828. }
  829. var list []Processinfo //[]annualaudit.OilAnnualAudit
  830. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  831. total = total + svc.GetProcessInfoWithOrderBytbl(OilAnnualAuditName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  832. processinfolist = append(processinfolist, list...)
  833. //datainfo.Items = processinfolist
  834. }
  835. if tabinx == "4" || tabinx == "0" {
  836. whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'"
  837. //企业用户必须加创建人条件
  838. if this.User.IsCompanyUser == 1 {
  839. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  840. }
  841. if supplierName != "" {
  842. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  843. }
  844. if CreateOn != "" {
  845. dates := strings.Split(CreateOn, ",")
  846. if len(dates) == 2 {
  847. minDate := dates[0]
  848. maxDate := dates[1]
  849. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  850. }
  851. }
  852. var list []Processinfo //[]infochange.OilInfoChange
  853. svc := infochange.GetInfoChangeService(utils.DBE)
  854. total = total + svc.GetProcessInfoWithOrderBytbl(OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  855. processinfolist = append(processinfolist, list...)
  856. //datainfo.Items = processinfolist
  857. }
  858. if tabinx == "5" {
  859. whereapp := "1=1 and WorkflowId != '' and WorkflowId != '0'"
  860. //企业用户必须加创建人条件
  861. if this.User.IsCompanyUser == 1 {
  862. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  863. }
  864. if supplierName != "" {
  865. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  866. }
  867. if CreateOn != "" {
  868. dates := strings.Split(CreateOn, ",")
  869. if len(dates) == 2 {
  870. minDate := dates[0]
  871. maxDate := dates[1]
  872. whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  873. }
  874. }
  875. svc := qualchange.GetQualChangeService(utils.DBE)
  876. var list []qualchange.OilQualChangeMain
  877. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  878. datainfo.Items = list
  879. }
  880. if tabinx == "0" {
  881. whereapp := "1=1 and WorkflowId != '' and WorkflowId != '0'"
  882. where1 := "1=1 and WorkflowId != '' and WorkflowId != '0'"
  883. where2 := "1=1 and WorkflowId != '' and WorkflowId != '0'"
  884. where3 := "1=1 and WorkflowId != '' and WorkflowId != '0'"
  885. //企业用户必须加创建人条件
  886. if this.User.IsCompanyUser == 1 {
  887. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  888. where1 = where1 + " and a.CreateUserId = '" + this.User.Id + "'"
  889. where2 = where2 + " and a.CreateUserId = '" + this.User.Id + "'"
  890. where3 = where3 + " and a.CreateUserId = '" + this.User.Id + "'"
  891. }
  892. if supplierTypeCode != "" {
  893. //whereapp = whereapp + " and a.SupplierTypeCode = '" + supplierTypeCode + "'"
  894. where1 = where1 + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  895. where2 = where2 + " and a.AppendType = '" + supplierTypeCode + "'"
  896. where3 = where3 + " and a.SupplierTypeName = '" + supplierTypeCode + "'"
  897. }
  898. if supplierName != "" {
  899. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  900. where1 = where1 + " and a.SupplierName like '%" + supplierName + "%'"
  901. where2 = where2 + " and a.SupplierName like '%" + supplierName + "%'"
  902. where3 = where3 + " and a.SupplierName like '%" + supplierName + "%'"
  903. }
  904. if CreateOn != "" {
  905. dates := strings.Split(CreateOn, ",")
  906. if len(dates) == 2 {
  907. minDate := dates[0]
  908. maxDate := dates[1]
  909. whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  910. }
  911. }
  912. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  913. var list []Processinfo
  914. svc.GetProcessInfoAllWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, whereapp, where1, where2, where3)
  915. processinfolist = list
  916. }
  917. sort.Slice(processinfolist, func(i, j int) bool {
  918. return processinfolist[i].CreateOn.Unix() > processinfolist[j].CreateOn.Unix()
  919. })
  920. datainfo.Items = processinfolist
  921. datainfo.CurrentItemCount = total
  922. datainfo.PageIndex = page.CurrentPage
  923. datainfo.ItemsPerPage = page.Size
  924. this.Data["json"] = &datainfo
  925. this.ServeJSON()
  926. }
  927. // @Title 准入范围查询
  928. // @Description
  929. // @Success 200 {object}
  930. // @router /zrfwselect [get]
  931. func (this *SelectController) ZrfwSelect() {
  932. //获取分页信息
  933. page := this.GetPageInfoForm()
  934. limitCurrent := (page.CurrentPage - 1) * page.Size
  935. svc := selectbusiness.GetSelectService(utils.DBE)
  936. supplierTypeCode := this.GetString("SupplierTypeCode")
  937. certsub := this.GetString("certsub")
  938. //企业用户必须加创建人条件
  939. var registerUser register.OilCorporateInfo
  940. var company supplier.OilSupplier
  941. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  942. svc.GetEntity(&registerUser, sql)
  943. if this.User.IsCompanyUser == 1 {
  944. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  945. svc.GetEntity(&company, sql1)
  946. }
  947. where := ""
  948. if certsub != "" {
  949. where = " and (Code like '%" + certsub + "%' or Name like '%" + certsub + "%')"
  950. }
  951. if company.SupplierName != "" {
  952. sql2 := "select distinct(Code),Name,SupplierId,CertSubStatus from OilSupplierCertSub where SupplierId='" + strconv.Itoa(company.Id) + "' and SupplierTypeCode='" + supplierTypeCode + "' " + where + " order by CertSubStatus desc,Code asc limit " + strconv.FormatInt(limitCurrent, 10) + "," + strconv.FormatInt(page.Size, 10) + ""
  953. result, _ := svc.DBE.QueryString(sql2)
  954. sql3 := "select count(distinct(Code)) total from OilSupplierCertSub where SupplierId='" + strconv.Itoa(company.Id) + "' and SupplierTypeCode='" + supplierTypeCode + "'" + where
  955. result1, _ := svc.DBE.QueryString(sql3)
  956. total, _ := strconv.ParseInt(result1[0]["total"], 10, 64)
  957. var datainfo DataInfo
  958. datainfo.Items = result
  959. datainfo.CurrentItemCount = total
  960. datainfo.PageIndex = page.CurrentPage
  961. datainfo.ItemsPerPage = page.Size
  962. this.Data["json"] = &datainfo
  963. this.ServeJSON()
  964. } else {
  965. var datainfo DataInfo
  966. datainfo.Items = ""
  967. datainfo.PageIndex = page.CurrentPage
  968. datainfo.ItemsPerPage = page.Size
  969. this.Data["json"] = &datainfo
  970. this.ServeJSON()
  971. }
  972. }
  973. // @Title 获取所有
  974. // @Description
  975. // @Success 200 {object}
  976. // @router /getallbusinesslist [post]
  977. func (this *SelectController) GetAllBusinesList() {
  978. perject := this.GetString("Perject")
  979. accessCardNo := this.GetString("AccessCardNo")
  980. supplierTypeCode := this.GetString("SupplierTypeCode")
  981. supplierName := this.GetString("SupplierName")
  982. var list []selectbusiness.SelectBusiness
  983. // 准入
  984. if perject == "1" || perject == "" {
  985. where := "1=1 "
  986. if accessCardNo != "" {
  987. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  988. }
  989. if supplierTypeCode != "" {
  990. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  991. }
  992. if supplierName != "" {
  993. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  994. }
  995. var zrlist []supplier.OilSupplierView
  996. zrsvc := supplier.GetOilSupplierService(utils.DBE)
  997. if this.User.IsCompanyUser == 1 {
  998. var registerUser register.OilCorporateInfo
  999. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  1000. zrsvc.GetEntity(&registerUser, sql)
  1001. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  1002. }
  1003. zrwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  1004. zrsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 100, "b.Id", false, &zrlist, zrwhere)
  1005. for _, item := range zrlist {
  1006. var sele selectbusiness.SelectBusiness
  1007. sele.SupplierName = item.SupplierName
  1008. sele.CreateOn = item.CreateOn
  1009. sele.AccessCardNo = item.AccessCardNo
  1010. sele.TypeCode = item.SupplierTypeCode
  1011. sele.TypeName = item.SupplierTypeName
  1012. sele.Preject = "1"
  1013. list = append(list, sele)
  1014. }
  1015. }
  1016. // 增项
  1017. if perject == "2" || perject == "" {
  1018. where := "1=1 "
  1019. if accessCardNo != "" {
  1020. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  1021. }
  1022. if supplierTypeCode != "" {
  1023. where = where + " and b.AppendType='" + supplierTypeCode + "'"
  1024. }
  1025. if supplierName != "" {
  1026. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  1027. }
  1028. var zxlist []suppliercertappend.OilSupplierCertAppend
  1029. zxsvc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  1030. if this.User.IsCompanyUser == 1 {
  1031. var registerUser register.OilCorporateInfo
  1032. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  1033. zxsvc.GetEntity(&registerUser, sql)
  1034. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  1035. }
  1036. zxwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  1037. zxsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, 1, 100, "b.Id", false, &zxlist, zxwhere)
  1038. for _, item := range zxlist {
  1039. var sele selectbusiness.SelectBusiness
  1040. sele.SupplierName = item.SupplierName
  1041. sele.CreateOn = item.CreateOn
  1042. sele.AccessCardNo = item.AccessCardNo
  1043. sele.TypeCode = item.AppendType
  1044. sele.TypeName = ""
  1045. sele.Preject = "2"
  1046. list = append(list, sele)
  1047. }
  1048. }
  1049. // 年审
  1050. if perject == "3" || perject == "" {
  1051. where := "1=1 "
  1052. if accessCardNo != "" {
  1053. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  1054. }
  1055. if supplierTypeCode != "" {
  1056. where = where + " and b.SupplierTypeName='" + supplierTypeCode + "'"
  1057. }
  1058. if supplierName != "" {
  1059. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  1060. }
  1061. var nslist []annualaudit.OilAnnualAudit
  1062. nssvc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  1063. if this.User.IsCompanyUser == 1 {
  1064. var registerUser register.OilCorporateInfo
  1065. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  1066. nssvc.GetEntity(&registerUser, sql)
  1067. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  1068. }
  1069. zswhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  1070. nssvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilAnnualAuditName, 1, 100, "b.Id", false, &nslist, zswhere)
  1071. for _, item := range nslist {
  1072. var sele selectbusiness.SelectBusiness
  1073. sele.SupplierName = item.SupplierName
  1074. sele.CreateOn = item.CreateOn
  1075. sele.AccessCardNo = item.AccessCardNo
  1076. sele.TypeCode = item.SupplierTypeName
  1077. sele.TypeName = ""
  1078. sele.Preject = "3"
  1079. list = append(list, sele)
  1080. }
  1081. }
  1082. // 变更申请
  1083. if perject == "4" || perject == "" {
  1084. where := "1=1 "
  1085. if accessCardNo != "" {
  1086. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  1087. }
  1088. if supplierTypeCode != "" {
  1089. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  1090. }
  1091. if supplierName != "" {
  1092. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  1093. }
  1094. var bglist []infochange.SuppModelInfo
  1095. bgsvc := infochange.GetInfoChangeService(utils.DBE)
  1096. if this.User.IsCompanyUser == 1 {
  1097. var registerUser register.OilCorporateInfo
  1098. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  1099. bgsvc.GetEntity(&registerUser, sql)
  1100. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  1101. }
  1102. bgwhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  1103. bgsvc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, 1, 100, "b.Id", false, &bglist, bgwhere)
  1104. for _, item := range bglist {
  1105. var sele selectbusiness.SelectBusiness
  1106. sele.SupplierName = item.SupplierName
  1107. sele.CreateOn = item.CreateOn
  1108. sele.AccessCardNo = ""
  1109. sele.TypeCode = item.SupplierTypeCode
  1110. sele.TypeName = item.SupplierTypeName
  1111. sele.Preject = "4"
  1112. list = append(list, sele)
  1113. }
  1114. }
  1115. var datainfo DataInfo
  1116. datainfo.Items = list
  1117. this.Data["json"] = &datainfo
  1118. this.ServeJSON()
  1119. }
  1120. // @Title 文件上传
  1121. // @Description get user by tokenaddsubfile
  1122. // @Success 200 {object} models.Userblood
  1123. // @router /filelist [get]
  1124. func (this *SelectController) FileList() {
  1125. page := this.GetPageInfoForm()
  1126. var list []supplierfile.OilSupplierFile
  1127. svc := supplierfile.GetSupplierfileService(utils.DBE)
  1128. where := " 1=1"
  1129. orderby := "SupplierTypeCode"
  1130. asc := true
  1131. Order := this.GetString("Order")
  1132. Prop := this.GetString("Prop")
  1133. subfilename := this.GetString("subfileName")
  1134. supplierId := this.GetString("SupplierId")
  1135. createOn := this.GetString("CreateOn")
  1136. if Order != "" && Prop != "" {
  1137. orderby = Prop
  1138. if Order == "asc" {
  1139. asc = true
  1140. }
  1141. }
  1142. //企业用户必须加创建人条件
  1143. var registerUser register.OilCorporateInfo
  1144. var company supplier.OilSupplier
  1145. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  1146. svc.GetEntity(&registerUser, sql)
  1147. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  1148. svc.GetEntity(&company, sql1)
  1149. if supplierId != "0" {
  1150. where = where + " and SupplierId=" + supplierId
  1151. } else {
  1152. where = where + " and SupplierId=" + strconv.Itoa(company.Id)
  1153. }
  1154. if subfilename != "" {
  1155. where = where + " and NeedFileType like '%" + subfilename + "%'"
  1156. }
  1157. if createOn != "" {
  1158. dates := strings.Split(createOn, ",")
  1159. if len(dates) == 2 {
  1160. minDate := dates[0]
  1161. maxDate := dates[1]
  1162. where = where + " and EffectDate>='" + minDate + "' and EffectDate<='" + maxDate + "'"
  1163. }
  1164. }
  1165. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  1166. var datainfo DataInfo
  1167. datainfo.Items = list
  1168. datainfo.CurrentItemCount = total
  1169. this.Data["json"] = &datainfo
  1170. this.ServeJSON()
  1171. }
  1172. // @Title 获取列表
  1173. // @Description
  1174. // @Success 200 {object}
  1175. // @router /totallist [get]
  1176. func (this *SelectController) GetTotalList() {
  1177. //获取分页信息
  1178. page := this.GetPageInfoForm()
  1179. where := "0"
  1180. orderby := "Id"
  1181. asc := false
  1182. Order := this.GetString("Order")
  1183. Prop := this.GetString("Prop")
  1184. if Order != "" && Prop != "" {
  1185. orderby = Prop
  1186. if Order == "asc" {
  1187. asc = true
  1188. }
  1189. }
  1190. Years := this.GetString("Years")
  1191. if Years != "" {
  1192. where = Years
  1193. }
  1194. //CreateOn := this.GetString("CreateOn")
  1195. //
  1196. //if CreateOn != "" {
  1197. // dates := strings.Split(CreateOn, ",")
  1198. // if len(dates) == 2 {
  1199. // minDate := dates[0]
  1200. // maxDate := dates[1]
  1201. // where = where + " and ValidityTo>='" + minDate + "' and ValidityTo<='" + maxDate + "'"
  1202. // }
  1203. //}
  1204. svc := selectbusiness.GetSelectService(utils.DBE)
  1205. var list []selectbusiness.TotalCount
  1206. svc.GetTotalInMonth(orderby, asc, &list, where)
  1207. var datainfo DataInfo
  1208. datainfo.Items = list
  1209. datainfo.PageIndex = page.CurrentPage
  1210. datainfo.ItemsPerPage = page.Size
  1211. this.Data["json"] = &datainfo
  1212. this.ServeJSON()
  1213. }
  1214. // @Title 导出资质图片
  1215. // @Description
  1216. // @Success 200 {object}
  1217. // @router /getallbusinesslicense [get]
  1218. func (this *SelectController) GetAllBusinessLicense() {
  1219. needFileType := this.GetString("NeedFileType")
  1220. svc := supplier.GetOilSupplierService(utils.DBE)
  1221. var supplierList []supplier.OilSupplier
  1222. where := "1=1"
  1223. svc.GetEntities(&supplierList, where)
  1224. _dir := utils.Cfg.MustValue("file", "tmplateDir") + needFileType
  1225. downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
  1226. for _, item := range supplierList {
  1227. var supplierFile supplierfile.OilSupplierFile
  1228. where := "SupplierId=" + strconv.Itoa(item.Id) + " and NeedFileType='" + needFileType + "'"
  1229. has := svc.GetEntity(&supplierFile, where)
  1230. if has {
  1231. fileArr := strings.Split(supplierFile.FileName, ".")
  1232. fileUrl := strings.Split(supplierFile.FileUrl, "|")
  1233. if len(fileUrl) == 2 && len(fileArr) == 2 {
  1234. utils.DownloadFile(downFileUrl+fileUrl[0], item.SupplierName+"."+fileArr[1], _dir)
  1235. }
  1236. }
  1237. }
  1238. //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
  1239. f1, _ := os.Open(_dir)
  1240. var files = []*os.File{f1}
  1241. //destZipName := time.Now().Format("2006-01-02")
  1242. destZipName := needFileType
  1243. destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
  1244. err := Compress(files, destZip)
  1245. retDocUrl := ""
  1246. if err == nil {
  1247. var sw *Seaweed
  1248. var filer []string
  1249. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1250. filer = []string{_filer}
  1251. }
  1252. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1253. _, _, fID, _ := sw.UploadFile(destZip, "", "")
  1254. retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1255. }
  1256. os.Remove(destZip)
  1257. os.RemoveAll(_dir)
  1258. var errinfo ErrorDataInfo
  1259. errinfo.Code = 0
  1260. errinfo.Item = retDocUrl
  1261. this.Data["json"] = &errinfo
  1262. this.ServeJSON()
  1263. }
  1264. // @Title 导出企业资质图片
  1265. // @Description
  1266. // @Success 200 {object}
  1267. // @router /getallbusinesslicensebyid [get]
  1268. func (this *SelectController) GetBusinessLicenseById() {
  1269. SupplierId := this.GetString("SupplierId")
  1270. SupplierName := this.GetString("SupplierName")
  1271. SupplierTypeCode := this.GetString("SupTypeCode")
  1272. svc := supplier.GetOilSupplierService(utils.DBE)
  1273. if SupplierId == "0" && this.User.IsCompanyUser == 1 {
  1274. var registerUser register.OilCorporateInfo
  1275. var company supplier.OilSupplier
  1276. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11"
  1277. svc.GetEntity(&registerUser, sql)
  1278. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  1279. svc.GetEntity(&company, sql1)
  1280. SupplierId = strconv.Itoa(company.Id)
  1281. SupplierName = company.SupplierName
  1282. }
  1283. _dir := utils.Cfg.MustValue("file", "tmplateDir") + SupplierName
  1284. downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
  1285. var supplierFile []supplierfile.OilSupplierFile
  1286. where := "SupplierId=" + SupplierId
  1287. svc.GetEntities(&supplierFile, where)
  1288. var errinfo ErrorDataInfo
  1289. if len(supplierFile) == 0 {
  1290. errinfo.Code = -1
  1291. errinfo.Message = "该公司没有可导出的资质!"
  1292. this.Data["json"] = &errinfo
  1293. this.ServeJSON()
  1294. return
  1295. }
  1296. for _, item := range supplierFile {
  1297. fileArr := strings.Split(item.FileName, ".")
  1298. fileUrl := strings.Split(item.FileUrl, "|")
  1299. if len(fileUrl) == 2 && len(fileArr) == 2 {
  1300. utils.DownloadFile(downFileUrl+fileUrl[0], item.NeedFileType+"."+fileArr[1], _dir)
  1301. }
  1302. }
  1303. //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
  1304. f1, _ := os.Open(_dir)
  1305. var files = []*os.File{f1}
  1306. if SupplierTypeCode == "01" {
  1307. SupplierTypeCode = "WZ"
  1308. } else if SupplierTypeCode == "02" {
  1309. SupplierTypeCode = "JS"
  1310. } else if SupplierTypeCode == "03" {
  1311. SupplierTypeCode = "JF"
  1312. } else {
  1313. SupplierTypeCode = ""
  1314. }
  1315. destZipName := SupplierName + time.Now().Format("20060102") + SupplierTypeCode
  1316. destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
  1317. err := Compress(files, destZip)
  1318. retDocUrl := ""
  1319. if err == nil {
  1320. var sw *Seaweed
  1321. var filer []string
  1322. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  1323. filer = []string{_filer}
  1324. }
  1325. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  1326. _, _, fID, _ := sw.UploadFile(destZip, "", "")
  1327. retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  1328. }
  1329. os.Remove(destZip)
  1330. os.RemoveAll(_dir)
  1331. errinfo.Code = 0
  1332. errinfo.Item = retDocUrl
  1333. this.Data["json"] = &errinfo
  1334. this.ServeJSON()
  1335. }
  1336. func Compress(files []*os.File, dest string) error {
  1337. d, _ := os.Create(dest)
  1338. defer d.Close()
  1339. w := zip.NewWriter(d)
  1340. defer w.Close()
  1341. for _, file := range files {
  1342. err := compress(file, "", w)
  1343. if err != nil {
  1344. return err
  1345. }
  1346. }
  1347. return nil
  1348. }
  1349. func compress(file *os.File, prefix string, zw *zip.Writer) error {
  1350. info, err := file.Stat()
  1351. if err != nil {
  1352. return err
  1353. }
  1354. if info.IsDir() {
  1355. prefix = prefix + "/" + info.Name()
  1356. fileInfos, err := file.Readdir(-1)
  1357. if err != nil {
  1358. return err
  1359. }
  1360. for _, fi := range fileInfos {
  1361. f, err := os.Open(file.Name() + "/" + fi.Name())
  1362. if err != nil {
  1363. return err
  1364. }
  1365. err = compress(f, prefix, zw)
  1366. if err != nil {
  1367. return err
  1368. }
  1369. }
  1370. } else {
  1371. header, err := zip.FileInfoHeader(info)
  1372. header.Name = prefix + "/" + header.Name
  1373. if err != nil {
  1374. return err
  1375. }
  1376. writer, err := zw.CreateHeader(header)
  1377. if err != nil {
  1378. return err
  1379. }
  1380. _, err = io.Copy(writer, file)
  1381. file.Close()
  1382. if err != nil {
  1383. return err
  1384. }
  1385. }
  1386. return nil
  1387. }
  1388. // @Title 获取资质列表
  1389. // @Description get user by tokenaddsubfile
  1390. // @Success 200 {object} models.Userblood
  1391. // @router /gettableheaderlist [get]
  1392. func (this *SelectController) GetTableHeaderList() {
  1393. typeCode := this.GetString("Type")
  1394. var tableHeader []tableheader.BaseTableheader
  1395. svc := tableheader.GetTableHeaderService(utils.DBE)
  1396. where := "CategoryCode='" + typeCode + "'"
  1397. svc.GetEntitysByWhere(BaseTableHeader, where, &tableHeader)
  1398. var errinfo ErrorDataInfo
  1399. errinfo.Code = 0
  1400. errinfo.Item = tableHeader
  1401. this.Data["json"] = &errinfo
  1402. this.ServeJSON()
  1403. }
  1404. // @Title 获取某个公司信息-安全管理平台-对外
  1405. // @Description
  1406. // @Success 200 {object}
  1407. // @router /getSupplierInfo [get]
  1408. func (this *SelectController) GetSupplierInfo() {
  1409. commercialNo := this.GetString("CommercialNo")
  1410. var errinfo ErrorInfo
  1411. if commercialNo == "" {
  1412. errinfo.Message = "操作失败!请求信息不完整"
  1413. errinfo.Code = -2
  1414. this.Data["json"] = &errinfo
  1415. this.ServeJSON()
  1416. return
  1417. }
  1418. where := "a.CommercialNo = '" + commercialNo + "'"
  1419. svc := selectbusiness.GetSelectService(utils.DBE)
  1420. var suppCertList []supplier.OilSupplierSelect2
  1421. svc.GetMyPagingEntitiesWithOrderBytbl2(&suppCertList, where)
  1422. for i,suppCert := range suppCertList {
  1423. var fileList []supplierfile.OilSupplierFileSelect
  1424. where1 := "SupplierId = " + strconv.Itoa(suppCert.Id) + " and SupplierTypeCode in ('000','" + suppCert.SupplierTypeCode + "')"
  1425. svc.GetFileList(&fileList, where1)
  1426. for ii,file := range fileList {
  1427. var fileList1 []supplierfile.OilSupplierFileSelect1
  1428. fileArr := strings.Split(file.FileUrl, "$")
  1429. for _,file1 := range fileArr {
  1430. var fileList2 supplierfile.OilSupplierFileSelect1
  1431. fileArr1 := strings.Split(file1, "|")
  1432. fileList2.FileUrl = fileArr1[0]
  1433. fileList2.FileName = fileArr1[1]
  1434. fileList1 = append(fileList1, fileList2)
  1435. }
  1436. fileList[ii].FileList = fileList1
  1437. }
  1438. suppCertList[i].FileList = fileList
  1439. var subList []suppliercertsub.OilSupplierCertSubSelect
  1440. where1 = "SupplierId = " + strconv.Itoa(suppCert.Id) + " and SupplierCertId = " + strconv.Itoa(suppCert.CertId)
  1441. svc.GetEntitysByWhere(OilSupplierCertSubName, where1, &subList)
  1442. suppCertList[i].SubList = subList
  1443. }
  1444. var datainfo DataInfo
  1445. datainfo.Items = suppCertList
  1446. this.Data["json"] = &datainfo
  1447. this.ServeJSON()
  1448. }