2
3

select.go 51 KB

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