select.go 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. package oilsupplier
  2. import (
  3. "archive/zip"
  4. "encoding/json"
  5. "fmt"
  6. "io"
  7. "os"
  8. "sort"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  13. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  14. "dashoo.cn/backend/api/business/oilsupplier/qualchange"
  15. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  16. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  17. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  18. "dashoo.cn/backend/api/business/oilsupplier/tableheader"
  19. "dashoo.cn/backend/api/business/register"
  20. // "fmt"
  21. "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
  22. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  23. . "dashoo.cn/backend/api/controllers"
  24. "dashoo.cn/utils"
  25. . "github.com/linxGnu/goseaweedfs"
  26. )
  27. type SelectController struct {
  28. BaseController
  29. }
  30. type UpSearch struct {
  31. FullName string
  32. }
  33. type UpInfoSearch struct {
  34. FullName string
  35. SupplierTypeName string
  36. HeGe int
  37. BuHeGe int
  38. ZongShu int
  39. Reason string
  40. }
  41. type Processinfo struct {
  42. Id int
  43. AccessCardNo string
  44. WorkflowId string
  45. ProcessKey string
  46. SupplierName string
  47. SupplierTypeCode string
  48. Status string
  49. Type string
  50. CreateOn time.Time
  51. AddinTime time.Time
  52. RecUnitName string
  53. ContactName string
  54. Mobile string
  55. }
  56. // @Title 获取所有
  57. // @Description
  58. // @Success 200 {object}
  59. // @router /getcompanylist [post]
  60. func (this *SelectController) GetTList() {
  61. var model supplier.OilSupplierSelect
  62. var model1 supplier.RegCapitalRange //注册资金范围
  63. //var model2 supplier.NeedFileTypeStruct //资质结构体
  64. var jsonBlob = this.Ctx.Input.RequestBody
  65. json.Unmarshal(jsonBlob, &model)
  66. json.Unmarshal(jsonBlob, &model1)
  67. //json.Unmarshal(jsonBlob, &model2)
  68. // //获取分页信息
  69. page := this.GetPageInfoForm()
  70. where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' "
  71. orderby := "a.Id"
  72. asc := true
  73. Order := this.GetString("Order")
  74. InFlag := this.GetString("InFlag")
  75. Prop := this.GetString("Prop")
  76. CheckUId := this.GetString("CheckUId")
  77. FullId := this.GetString("FullId")
  78. if Order != "" && Prop != "" {
  79. orderby = Prop
  80. if Order == "desc" {
  81. asc = false
  82. }
  83. }
  84. //准入证号
  85. if model.AccessCardNo != "" {
  86. where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
  87. }
  88. if InFlag != "" {
  89. where = where + " and b.InFlag = " + InFlag
  90. }
  91. //企业名称
  92. if model.SupplierName != "" {
  93. where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
  94. }
  95. if model.OldSupplierName != "" {
  96. where = where + " and a.OldSupplierName like '%" + model.OldSupplierName + "%'"
  97. }
  98. if FullId != "" {
  99. where = where + " and f.Id = '" + FullId + "'"
  100. }
  101. if CheckUId != "" {
  102. where = where + " and b.RecUnitId = '" + CheckUId + "'"
  103. }
  104. //准入类别(基建,物资,技术服务)
  105. if model.SupplierTypeCode != "" {
  106. where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
  107. }
  108. //准入标识 1 准入 2 暂停 3取消
  109. if model.InFlag != "" {
  110. where = where + " and b.InFlag = '" + model.InFlag + "'"
  111. }
  112. //法人
  113. if model.LegalPerson != "" {
  114. where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
  115. }
  116. //联系人
  117. if model.ContactName != "" {
  118. where = where + " and a.ContactName like '%" + model.ContactName + "%'"
  119. }
  120. //统一社会信用代码
  121. if model.CommercialNo != "" {
  122. where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
  123. }
  124. //开户银行
  125. if model.DepositBank != "" {
  126. where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
  127. }
  128. //HSE审查
  129. if model.HseTraining != "" {
  130. where = where + " and a.HseTraining = '" + model.HseTraining + "'"
  131. }
  132. //公司类型
  133. if model.CompanyType != "" {
  134. where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
  135. }
  136. //成立时间
  137. SetupTime := this.GetString("SetupTime")
  138. if SetupTime != "" {
  139. where = where + " and a.SetupTime ='" + SetupTime + "'"
  140. }
  141. //注册资金范围
  142. if model1.RegCapital1 != "" {
  143. where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
  144. }
  145. if model1.RegCapital2 != "" {
  146. where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
  147. }
  148. //注册省份
  149. if model.Province != "" {
  150. where = where + " and a.Province = '" + model.Province + "'"
  151. }
  152. //注册市
  153. if model.City != "" {
  154. where = where + " and a.City = '" + model.City + "'"
  155. }
  156. //注册区
  157. if model.Street != "" {
  158. where = where + " and a.Street = '" + model.Street + "'"
  159. }
  160. //注册详细地址
  161. if model.Address != "" {
  162. where = where + " and a.Address like '%" + model.Address + "%'"
  163. }
  164. if model.LinkProvince != "" {
  165. where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
  166. }
  167. if model.LinkCity != "" {
  168. where = where + " and a.LinkCity = '" + model.LinkCity + "'"
  169. }
  170. if model.LinkStreet != "" {
  171. where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
  172. }
  173. if model.LinkAddress != "" {
  174. where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
  175. }
  176. //营业范围
  177. if model.BusinessScope != "" {
  178. where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
  179. }
  180. CreateOn := this.GetString("CreateOn")
  181. if CreateOn != "" {
  182. dates := strings.Split(CreateOn, ",")
  183. if len(dates) == 2 {
  184. minDate := dates[0]
  185. maxDate := dates[1]
  186. where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  187. }
  188. }
  189. a := model.InStyle
  190. fmt.Println(a)
  191. //准入方式
  192. if model.InStyle != "" {
  193. if model.InStyle == "0" {
  194. where = where + " and b.InStyle in ('2','3','4','5')"
  195. } else {
  196. where = where + " and b.InStyle ='" + model.InStyle + "'"
  197. }
  198. }
  199. //包含资质
  200. //if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 {
  201. // pararm := ""
  202. // for i := 0; i < len(model2.NeedFileType); i++ {
  203. //
  204. // pararm = pararm + "'" + model2.NeedFileType[i] + "',"
  205. //
  206. // }
  207. // fmt.Println(pararm[0 : len(pararm)-1])
  208. // where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")"
  209. //}
  210. having := ""
  211. CerSubName := strings.Split(model.CerSubName, ",")
  212. comma := strings.Contains(model.CerSubName, ",")
  213. if comma {
  214. CerSubName = strings.Split(model.CerSubName, ",")
  215. } else {
  216. CerSubName = strings.Split(model.CerSubName, ",")
  217. }
  218. var Ids supplier.OilCertIds
  219. //准入范围
  220. if model.CerSubName != "" {
  221. svc := supplier.GetOilSupplierService(utils.DBE)
  222. where1 := ""
  223. for key, value := range CerSubName {
  224. if key == 0 {
  225. where1 += " (Name like '%" + value + "%' or Code like '" + value + "%' "
  226. } else {
  227. where1 += "or Name like '%" + value + "%' or Code like '" + value + "%' "
  228. }
  229. }
  230. where1 += ") "
  231. svc.GetCertIds(&Ids, where1)
  232. }
  233. //资质
  234. if model.NeedFileType != "" {
  235. having = " having NeedFileType like '%" + model.NeedFileType + "%' "
  236. }
  237. svc := selectbusiness.GetSelectService(utils.DBE)
  238. var list []supplier.OilSupplierSelect
  239. total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
  240. OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids, model.NeedFileType)
  241. var datainfo DataInfo
  242. datainfo.Items = list
  243. datainfo.CurrentItemCount = total
  244. datainfo.PageIndex = page.CurrentPage
  245. datainfo.ItemsPerPage = page.Size
  246. this.Data["json"] = &datainfo
  247. this.ServeJSON()
  248. }
  249. // @Title 根据公司名获取公司信息和准入
  250. // @Description
  251. // @Success 200 {object}
  252. // @router /getbaseinfo [post]
  253. func (this *SelectController) GetBaseInfo() {
  254. Spesearch := this.GetString("Spesearch")
  255. spesearchs := strings.Split(Spesearch, ",")
  256. svc := selectbusiness.GetSelectService(utils.DBE)
  257. var infoIntelist []supplier.OilSupplierInte
  258. for _, item := range spesearchs {
  259. //var supplierinfo supplier.SupplierInfoInte
  260. var infoInte supplier.OilSupplierInte
  261. where := " where 1 = 1 AND a.SupplierName = '" + item + "'"
  262. svc.GetInfoByCompId(where, &infoInte.SupplierInfo)
  263. var cert1 suppliercert.OilSupplierCert
  264. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'"
  265. svc.GetEntityByWhere(OilSupplierCertName, where, &cert1)
  266. infoInte.SupplierInfo.WZStatus = cert1.InFlag
  267. infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02")
  268. var cert2 suppliercert.OilSupplierCert
  269. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'"
  270. svc.GetEntityByWhere(OilSupplierCertName, where, &cert2)
  271. infoInte.SupplierInfo.JSStatus = cert2.InFlag
  272. infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02")
  273. var cert3 suppliercert.OilSupplierCert
  274. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'"
  275. svc.GetEntityByWhere(OilSupplierCertName, where, &cert3)
  276. infoInte.SupplierInfo.JFStatus = cert3.InFlag
  277. infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02")
  278. if infoInte.SupplierInfo.SupplierName != "" {
  279. //var suplliersup []supplier.OilSupplierCertSubInte
  280. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'"
  281. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  282. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'"
  283. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  284. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'"
  285. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  286. } else if item == "" {
  287. where = "where SupplierTypeCode='01'"
  288. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  289. where = "where and SupplierTypeCode='02'"
  290. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  291. where = "where SupplierTypeCode='03'"
  292. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  293. }
  294. infoIntelist = append(infoIntelist, infoInte)
  295. }
  296. var datainfo DataInfo
  297. datainfo.Items = infoIntelist
  298. this.Data["json"] = &datainfo
  299. this.ServeJSON()
  300. }
  301. // @Title 根据分页获取公司信息和准入, // 提供给银行接口的用户名 和 密码:ceshi1, Ceshi111
  302. // @Description
  303. // @Success 200 {object}
  304. // @router /getinfobypage [post]
  305. func (this *SelectController) GetInfoByPage() {
  306. page := this.GetString("page")
  307. svc := selectbusiness.GetSelectService(utils.DBE)
  308. var infoIntelist []supplier.OilSupplierInte
  309. intpage, _ := strconv.Atoi(page)
  310. for i := (intpage - 1) * 50; i < (intpage * 50); i++ {
  311. //var supplierinfo supplier.SupplierInfoInte
  312. var infoInte supplier.OilSupplierInte
  313. stringi := strconv.Itoa(i)
  314. where := " where 1 = 1 limit " + stringi + ",1"
  315. svc.GetInfoByCompId(where, &infoInte.SupplierInfo)
  316. var cert1 suppliercert.OilSupplierCert
  317. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'"
  318. svc.GetEntityByWhere(OilSupplierCertName, where, &cert1)
  319. infoInte.SupplierInfo.WZStatus = cert1.InFlag
  320. infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02")
  321. var cert2 suppliercert.OilSupplierCert
  322. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'"
  323. svc.GetEntityByWhere(OilSupplierCertName, where, &cert2)
  324. infoInte.SupplierInfo.JSStatus = cert2.InFlag
  325. infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02")
  326. var cert3 suppliercert.OilSupplierCert
  327. where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'"
  328. svc.GetEntityByWhere(OilSupplierCertName, where, &cert3)
  329. infoInte.SupplierInfo.JFStatus = cert3.InFlag
  330. infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02")
  331. if infoInte.SupplierInfo.SupplierName != "" {
  332. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'"
  333. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub)
  334. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'"
  335. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub)
  336. where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'"
  337. svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub)
  338. }
  339. if infoInte.SupplierInfo.Id != 0 {
  340. infoIntelist = append(infoIntelist, infoInte)
  341. }
  342. }
  343. var datainfo DataInfo
  344. datainfo.Items = infoIntelist
  345. this.Data["json"] = &datainfo
  346. this.ServeJSON()
  347. }
  348. // @Title 获取所有
  349. // @Description
  350. // @Success 200 {object}
  351. // @router /up [post]
  352. func (this *SelectController) Up() {
  353. var model UpSearch
  354. var jsonBlob = this.Ctx.Input.RequestBody
  355. json.Unmarshal(jsonBlob, &model)
  356. // //获取分页信息
  357. page := this.GetPageInfoForm()
  358. where := ""
  359. asc := false
  360. Order := this.GetString("Order")
  361. Prop := this.GetString("Prop")
  362. CreateOn := this.GetString("CreateOn")
  363. if Order != "" && Prop != "" {
  364. if Order == "asc" {
  365. asc = true
  366. }
  367. }
  368. if CreateOn != "" {
  369. dates := strings.Split(CreateOn, ",")
  370. if len(dates) == 2 {
  371. minDate := dates[0]
  372. maxDate := dates[1]
  373. where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  374. }
  375. }
  376. if model.FullName != "" {
  377. where = where + " and (select FullName from Base_Organize where Id = a.CommitComId) like '%" + model.FullName + "%'"
  378. }
  379. svc := selectbusiness.GetSelectService(utils.DBE)
  380. var list []UpInfoSearch
  381. total := svc.GetUp(OilSupplierCertName, page.CurrentPage, page.Size, Prop, asc, &list, where)
  382. var datainfo DataInfo
  383. datainfo.Items = list
  384. datainfo.CurrentItemCount = total
  385. datainfo.PageIndex = page.CurrentPage
  386. datainfo.ItemsPerPage = page.Size
  387. this.Data["json"] = &datainfo
  388. this.ServeJSON()
  389. }
  390. // @Title 获取所有资质名称
  391. // @Description
  392. // @Success 200 {object}
  393. // @router /getnftoptions [post]
  394. func (this *SelectController) GetNFTOptions() {
  395. svc := selectbusiness.GetSelectService(utils.DBE)
  396. var list []map[string]string
  397. sql := "select distinct(Name) from " + BaseTableHeader + ""
  398. list, _ = svc.DBE.QueryString(sql)
  399. var datainfo DataInfo
  400. datainfo.Items = list
  401. this.Data["json"] = &datainfo
  402. this.ServeJSON()
  403. }
  404. // @Title 流程查询准入
  405. // @Description
  406. // @Success 200 {object}
  407. // @router /getprocessauditlist [get]
  408. func (this *SelectController) GetProcessAuditList() {
  409. //获取分页信息
  410. page := this.GetPageInfoForm()
  411. where := " 1=1 "
  412. orderby := "Id"
  413. asc := false
  414. Order := this.GetString("Order")
  415. Prop := this.GetString("Prop")
  416. if Order != "" && Prop != "" {
  417. orderby = Prop
  418. if Order == "asc" {
  419. asc = true
  420. }
  421. }
  422. svc := supplier.GetOilSupplierService(utils.DBE)
  423. tabinx := this.GetString("tabinx")
  424. supplierTypeCode := this.GetString("SupplierTypeCode")
  425. supplierName := this.GetString("SupplierName")
  426. CreateOn := this.GetString("CreateOn")
  427. //企业用户必须加创建人条件
  428. var registerUser register.OilCorporateInfo
  429. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  430. svc.GetEntity(&registerUser, sql)
  431. var processinfolist []Processinfo
  432. if this.User.IsCompanyUser == 1 {
  433. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  434. }
  435. if supplierTypeCode != "" {
  436. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  437. }
  438. if supplierName != "" {
  439. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  440. }
  441. var total int64 = 0
  442. var datainfo DataInfo
  443. if tabinx == "1" || tabinx == "0" {
  444. var list []Processinfo //[]supplier.OilSupplierView
  445. if CreateOn != "" {
  446. dates := strings.Split(CreateOn, ",")
  447. if len(dates) == 2 {
  448. minDate := dates[0]
  449. maxDate := dates[1]
  450. where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
  451. }
  452. }
  453. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, "b.Id", asc, &list, where)
  454. processinfolist = append(processinfolist, list...)
  455. //datainfo.Items = processinfolist
  456. }
  457. if tabinx == "2" || tabinx == "0" {
  458. whereapp := "1=1"
  459. //企业用户必须加创建人条件
  460. if this.User.IsCompanyUser == 1 {
  461. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  462. }
  463. if supplierTypeCode != "" {
  464. whereapp = whereapp + " and a.AppendType like '%" + supplierTypeCode + "%'"
  465. }
  466. if supplierName != "" {
  467. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  468. }
  469. if CreateOn != "" {
  470. dates := strings.Split(CreateOn, ",")
  471. if len(dates) == 2 {
  472. minDate := dates[0]
  473. maxDate := dates[1]
  474. whereapp = whereapp + " a.and CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  475. }
  476. }
  477. var list []Processinfo //[]suppliercertappend.OilSupplierCertAppend
  478. svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  479. total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierCertAppendName, page.CurrentPage, page.Size, "a.Id", asc, &list, whereapp)
  480. processinfolist = append(processinfolist, list...)
  481. //datainfo.Items = processinfolist
  482. }
  483. if tabinx == "3" || tabinx == "0" {
  484. whereapp := "1=1"
  485. //企业用户必须加创建人条件
  486. if this.User.IsCompanyUser == 1 {
  487. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  488. }
  489. if supplierTypeCode != "" {
  490. whereapp = whereapp + " and a.SupplierTypeName = '" + supplierTypeCode + "'"
  491. }
  492. if supplierName != "" {
  493. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  494. }
  495. if CreateOn != "" {
  496. dates := strings.Split(CreateOn, ",")
  497. if len(dates) == 2 {
  498. minDate := dates[0]
  499. maxDate := dates[1]
  500. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  501. }
  502. }
  503. var list []Processinfo //[]annualaudit.OilAnnualAudit
  504. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  505. total = total + svc.GetProcessInfoWithOrderBytbl(OilAnnualAuditName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  506. processinfolist = append(processinfolist, list...)
  507. //datainfo.Items = processinfolist
  508. }
  509. if tabinx == "4" || tabinx == "0" {
  510. whereapp := "1=1"
  511. //企业用户必须加创建人条件
  512. if this.User.IsCompanyUser == 1 {
  513. whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
  514. }
  515. if supplierName != "" {
  516. whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'"
  517. }
  518. if CreateOn != "" {
  519. dates := strings.Split(CreateOn, ",")
  520. if len(dates) == 2 {
  521. minDate := dates[0]
  522. maxDate := dates[1]
  523. whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
  524. }
  525. }
  526. var list []Processinfo //[]infochange.OilInfoChange
  527. svc := infochange.GetInfoChangeService(utils.DBE)
  528. total = total + svc.GetProcessInfoWithOrderBytbl(OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  529. processinfolist = append(processinfolist, list...)
  530. //datainfo.Items = processinfolist
  531. }
  532. if tabinx == "5" {
  533. whereapp := "1=1"
  534. //企业用户必须加创建人条件
  535. if this.User.IsCompanyUser == 1 {
  536. whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
  537. }
  538. if supplierName != "" {
  539. whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
  540. }
  541. if CreateOn != "" {
  542. dates := strings.Split(CreateOn, ",")
  543. if len(dates) == 2 {
  544. minDate := dates[0]
  545. maxDate := dates[1]
  546. whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
  547. }
  548. }
  549. svc := qualchange.GetQualChangeService(utils.DBE)
  550. var list []qualchange.OilQualChangeMain
  551. total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
  552. datainfo.Items = list
  553. }
  554. sort.Slice(processinfolist, func(i, j int) bool {
  555. return processinfolist[i].CreateOn.Unix() > processinfolist[j].CreateOn.Unix()
  556. })
  557. datainfo.Items = processinfolist
  558. datainfo.CurrentItemCount = total
  559. datainfo.PageIndex = page.CurrentPage
  560. datainfo.ItemsPerPage = page.Size
  561. this.Data["json"] = &datainfo
  562. this.ServeJSON()
  563. }
  564. // @Title 准入范围查询
  565. // @Description
  566. // @Success 200 {object}
  567. // @router /zrfwselect [get]
  568. func (this *SelectController) ZrfwSelect() {
  569. //获取分页信息
  570. page := this.GetPageInfoForm()
  571. limitCurrent := (page.CurrentPage - 1) * page.Size
  572. svc := selectbusiness.GetSelectService(utils.DBE)
  573. supplierTypeCode := this.GetString("SupplierTypeCode")
  574. certsub := this.GetString("certsub")
  575. //企业用户必须加创建人条件
  576. var registerUser register.OilCorporateInfo
  577. var company supplier.OilSupplier
  578. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  579. svc.GetEntity(&registerUser, sql)
  580. if this.User.IsCompanyUser == 1 {
  581. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  582. svc.GetEntity(&company, sql1)
  583. }
  584. where := ""
  585. if certsub != "" {
  586. where = " and (Code like '%" + certsub + "%' or Name like '%" + certsub + "%')"
  587. }
  588. if company.SupplierName != "" {
  589. 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) + ""
  590. result, _ := svc.DBE.QueryString(sql2)
  591. sql3 := "select count(distinct(Code)) total from OilSupplierCertSub where SupplierId='" + strconv.Itoa(company.Id) + "' and SupplierTypeCode='" + supplierTypeCode + "'" + where
  592. result1, _ := svc.DBE.QueryString(sql3)
  593. total, _ := strconv.ParseInt(result1[0]["total"], 10, 64)
  594. var datainfo DataInfo
  595. datainfo.Items = result
  596. datainfo.CurrentItemCount = total
  597. datainfo.PageIndex = page.CurrentPage
  598. datainfo.ItemsPerPage = page.Size
  599. this.Data["json"] = &datainfo
  600. this.ServeJSON()
  601. } else {
  602. var datainfo DataInfo
  603. datainfo.Items = ""
  604. datainfo.PageIndex = page.CurrentPage
  605. datainfo.ItemsPerPage = page.Size
  606. this.Data["json"] = &datainfo
  607. this.ServeJSON()
  608. }
  609. }
  610. // @Title 获取所有
  611. // @Description
  612. // @Success 200 {object}
  613. // @router /getallbusinesslist [post]
  614. func (this *SelectController) GetAllBusinesList() {
  615. perject := this.GetString("Perject")
  616. accessCardNo := this.GetString("AccessCardNo")
  617. supplierTypeCode := this.GetString("SupplierTypeCode")
  618. supplierName := this.GetString("SupplierName")
  619. var list []selectbusiness.SelectBusiness
  620. // 准入
  621. if perject == "1" || perject == "" {
  622. where := "1=1 "
  623. if accessCardNo != "" {
  624. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  625. }
  626. if supplierTypeCode != "" {
  627. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  628. }
  629. if supplierName != "" {
  630. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  631. }
  632. var zrlist []supplier.OilSupplierView
  633. zrsvc := supplier.GetOilSupplierService(utils.DBE)
  634. if this.User.IsCompanyUser == 1 {
  635. var registerUser register.OilCorporateInfo
  636. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  637. zrsvc.GetEntity(&registerUser, sql)
  638. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  639. }
  640. zrwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  641. zrsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 100, "b.Id", false, &zrlist, zrwhere)
  642. for _, item := range zrlist {
  643. var sele selectbusiness.SelectBusiness
  644. sele.SupplierName = item.SupplierName
  645. sele.CreateOn = item.CreateOn
  646. sele.AccessCardNo = item.AccessCardNo
  647. sele.TypeCode = item.SupplierTypeCode
  648. sele.TypeName = item.SupplierTypeName
  649. sele.Preject = "1"
  650. list = append(list, sele)
  651. }
  652. }
  653. // 增项
  654. if perject == "2" || perject == "" {
  655. where := "1=1 "
  656. if accessCardNo != "" {
  657. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  658. }
  659. if supplierTypeCode != "" {
  660. where = where + " and b.AppendType='" + supplierTypeCode + "'"
  661. }
  662. if supplierName != "" {
  663. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  664. }
  665. var zxlist []suppliercertappend.OilSupplierCertAppend
  666. zxsvc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  667. if this.User.IsCompanyUser == 1 {
  668. var registerUser register.OilCorporateInfo
  669. sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 "
  670. zxsvc.GetEntity(&registerUser, sql)
  671. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  672. }
  673. zxwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'"
  674. zxsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, 1, 100, "b.Id", false, &zxlist, zxwhere)
  675. for _, item := range zxlist {
  676. var sele selectbusiness.SelectBusiness
  677. sele.SupplierName = item.SupplierName
  678. sele.CreateOn = item.CreateOn
  679. sele.AccessCardNo = item.AccessCardNo
  680. sele.TypeCode = item.AppendType
  681. sele.TypeName = ""
  682. sele.Preject = "2"
  683. list = append(list, sele)
  684. }
  685. }
  686. // 年审
  687. if perject == "3" || perject == "" {
  688. where := "1=1 "
  689. if accessCardNo != "" {
  690. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  691. }
  692. if supplierTypeCode != "" {
  693. where = where + " and b.SupplierTypeName='" + supplierTypeCode + "'"
  694. }
  695. if supplierName != "" {
  696. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  697. }
  698. var nslist []annualaudit.OilAnnualAudit
  699. nssvc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  700. if this.User.IsCompanyUser == 1 {
  701. var registerUser register.OilCorporateInfo
  702. sql := " UserName='" + this.User.Username + "'"
  703. nssvc.GetEntity(&registerUser, sql)
  704. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  705. }
  706. zswhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  707. nssvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilAnnualAuditName, 1, 100, "b.Id", false, &nslist, zswhere)
  708. for _, item := range nslist {
  709. var sele selectbusiness.SelectBusiness
  710. sele.SupplierName = item.SupplierName
  711. sele.CreateOn = item.CreateOn
  712. sele.AccessCardNo = item.AccessCardNo
  713. sele.TypeCode = item.SupplierTypeName
  714. sele.TypeName = ""
  715. sele.Preject = "3"
  716. list = append(list, sele)
  717. }
  718. }
  719. // 变更申请
  720. if perject == "4" || perject == "" {
  721. where := "1=1 "
  722. if accessCardNo != "" {
  723. where = where + " and b.AccessCardNo='" + accessCardNo + "'"
  724. }
  725. if supplierTypeCode != "" {
  726. where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'"
  727. }
  728. if supplierName != "" {
  729. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  730. }
  731. var bglist []infochange.SuppModelInfo
  732. bgsvc := infochange.GetInfoChangeService(utils.DBE)
  733. if this.User.IsCompanyUser == 1 {
  734. var registerUser register.OilCorporateInfo
  735. sql := " UserName='" + this.User.Username + "'"
  736. bgsvc.GetEntity(&registerUser, sql)
  737. where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
  738. }
  739. bgwhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'"
  740. bgsvc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, 1, 100, "b.Id", false, &bglist, bgwhere)
  741. for _, item := range bglist {
  742. var sele selectbusiness.SelectBusiness
  743. sele.SupplierName = item.SupplierName
  744. sele.CreateOn = item.CreateOn
  745. sele.AccessCardNo = ""
  746. sele.TypeCode = item.SupplierTypeCode
  747. sele.TypeName = item.SupplierTypeName
  748. sele.Preject = "4"
  749. list = append(list, sele)
  750. }
  751. }
  752. var datainfo DataInfo
  753. datainfo.Items = list
  754. this.Data["json"] = &datainfo
  755. this.ServeJSON()
  756. }
  757. // @Title 文件上传
  758. // @Description get user by tokenaddsubfile
  759. // @Success 200 {object} models.Userblood
  760. // @router /filelist [get]
  761. func (this *SelectController) FileList() {
  762. page := this.GetPageInfoForm()
  763. var list []supplierfile.OilSupplierFile
  764. svc := supplierfile.GetSupplierfileService(utils.DBE)
  765. where := " 1=1"
  766. orderby := "Id"
  767. asc := true
  768. Order := this.GetString("Order")
  769. Prop := this.GetString("Prop")
  770. subfilename := this.GetString("subfileName")
  771. supplierId := this.GetString("SupplierId")
  772. createOn := this.GetString("CreateOn")
  773. if Order != "" && Prop != "" {
  774. orderby = Prop
  775. if Order == "asc" {
  776. asc = true
  777. }
  778. }
  779. //企业用户必须加创建人条件
  780. var registerUser register.OilCorporateInfo
  781. var company supplier.OilSupplier
  782. sql := " UserName='" + this.User.Username + "'"
  783. svc.GetEntity(&registerUser, sql)
  784. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  785. svc.GetEntity(&company, sql1)
  786. if supplierId != "0" {
  787. where = where + " and SupplierId=" + supplierId
  788. } else {
  789. where = where + " and SupplierId=" + strconv.Itoa(company.Id)
  790. }
  791. if subfilename != "" {
  792. where = where + " and NeedFileType like '%" + subfilename + "%'"
  793. }
  794. if createOn != "" {
  795. dates := strings.Split(createOn, ",")
  796. if len(dates) == 2 {
  797. minDate := dates[0]
  798. maxDate := dates[1]
  799. where = where + " and EffectDate>='" + minDate + "' and EffectDate<='" + maxDate + "'"
  800. }
  801. }
  802. total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
  803. var datainfo DataInfo
  804. datainfo.Items = list
  805. datainfo.CurrentItemCount = total
  806. this.Data["json"] = &datainfo
  807. this.ServeJSON()
  808. }
  809. // @Title 获取列表
  810. // @Description
  811. // @Success 200 {object}
  812. // @router /totallist [get]
  813. func (this *SelectController) GetTotalList() {
  814. //获取分页信息
  815. page := this.GetPageInfoForm()
  816. where := "0"
  817. orderby := "Id"
  818. asc := false
  819. Order := this.GetString("Order")
  820. Prop := this.GetString("Prop")
  821. if Order != "" && Prop != "" {
  822. orderby = Prop
  823. if Order == "asc" {
  824. asc = true
  825. }
  826. }
  827. Years := this.GetString("Years")
  828. if Years != "" {
  829. where = Years
  830. }
  831. //CreateOn := this.GetString("CreateOn")
  832. //
  833. //if CreateOn != "" {
  834. // dates := strings.Split(CreateOn, ",")
  835. // if len(dates) == 2 {
  836. // minDate := dates[0]
  837. // maxDate := dates[1]
  838. // where = where + " and ValidityTo>='" + minDate + "' and ValidityTo<='" + maxDate + "'"
  839. // }
  840. //}
  841. svc := selectbusiness.GetSelectService(utils.DBE)
  842. var list []selectbusiness.TotalCount
  843. svc.GetTotalInMonth(orderby, asc, &list, where)
  844. var datainfo DataInfo
  845. datainfo.Items = list
  846. datainfo.PageIndex = page.CurrentPage
  847. datainfo.ItemsPerPage = page.Size
  848. this.Data["json"] = &datainfo
  849. this.ServeJSON()
  850. }
  851. // @Title 导出资质图片
  852. // @Description
  853. // @Success 200 {object}
  854. // @router /getallbusinesslicense [get]
  855. func (this *SelectController) GetAllBusinessLicense() {
  856. needFileType := this.GetString("NeedFileType")
  857. svc := supplier.GetOilSupplierService(utils.DBE)
  858. var supplierList []supplier.OilSupplier
  859. where := "1=1"
  860. svc.GetEntities(&supplierList, where)
  861. _dir := utils.Cfg.MustValue("file", "tmplateDir") + needFileType
  862. downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
  863. for _, item := range supplierList {
  864. var supplierFile supplierfile.OilSupplierFile
  865. where := "SupplierId=" + strconv.Itoa(item.Id) + " and NeedFileType='" + needFileType + "'"
  866. has := svc.GetEntity(&supplierFile, where)
  867. if has {
  868. fileArr := strings.Split(supplierFile.FileName, ".")
  869. fileUrl := strings.Split(supplierFile.FileUrl, "|")
  870. if len(fileUrl) == 2 && len(fileArr) == 2 {
  871. utils.DownloadFile(downFileUrl+fileUrl[0], item.SupplierName+"."+fileArr[1], _dir)
  872. }
  873. }
  874. }
  875. //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
  876. f1, _ := os.Open(_dir)
  877. var files = []*os.File{f1}
  878. //destZipName := time.Now().Format("2006-01-02")
  879. destZipName := needFileType
  880. destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
  881. err := Compress(files, destZip)
  882. retDocUrl := ""
  883. if err == nil {
  884. var sw *Seaweed
  885. var filer []string
  886. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  887. filer = []string{_filer}
  888. }
  889. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  890. _, _, fID, _ := sw.UploadFile(destZip, "", "")
  891. retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  892. }
  893. os.Remove(destZip)
  894. // os.RemoveAll(_dir)
  895. var errinfo ErrorDataInfo
  896. errinfo.Code = 0
  897. errinfo.Item = retDocUrl
  898. this.Data["json"] = &errinfo
  899. this.ServeJSON()
  900. }
  901. // @Title 导出企业资质图片
  902. // @Description
  903. // @Success 200 {object}
  904. // @router /getallbusinesslicensebyid [get]
  905. func (this *SelectController) GetBusinessLicenseById() {
  906. SupplierId := this.GetString("SupplierId")
  907. SupplierName := this.GetString("SupplierName")
  908. SupplierTypeCode := this.GetString("SupTypeCode")
  909. svc := supplier.GetOilSupplierService(utils.DBE)
  910. if SupplierId == "0" && this.User.IsCompanyUser == 1 {
  911. var registerUser register.OilCorporateInfo
  912. var company supplier.OilSupplier
  913. sql := " UserName='" + this.User.Username + "'"
  914. svc.GetEntity(&registerUser, sql)
  915. sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'"
  916. svc.GetEntity(&company, sql1)
  917. SupplierId = strconv.Itoa(company.Id)
  918. SupplierName = company.SupplierName
  919. }
  920. _dir := utils.Cfg.MustValue("file", "tmplateDir") + SupplierName
  921. downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP")
  922. var supplierFile []supplierfile.OilSupplierFile
  923. where := "SupplierId=" + SupplierId
  924. svc.GetEntities(&supplierFile, where)
  925. var errinfo ErrorDataInfo
  926. if len(supplierFile) == 0 {
  927. errinfo.Code = -1
  928. errinfo.Message = "该公司没有可导出的资质!"
  929. this.Data["json"] = &errinfo
  930. this.ServeJSON()
  931. return
  932. }
  933. for _, item := range supplierFile {
  934. fileArr := strings.Split(item.FileName, ".")
  935. fileUrl := strings.Split(item.FileUrl, "|")
  936. if len(fileUrl) == 2 && len(fileArr) == 2 {
  937. utils.DownloadFile(downFileUrl+fileUrl[0], item.NeedFileType+"."+fileArr[1], _dir)
  938. }
  939. }
  940. //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip")
  941. f1, _ := os.Open(_dir)
  942. var files = []*os.File{f1}
  943. if SupplierTypeCode == "01" {
  944. SupplierTypeCode = "WZ"
  945. } else if SupplierTypeCode == "02" {
  946. SupplierTypeCode = "JS"
  947. } else if SupplierTypeCode == "03" {
  948. SupplierTypeCode = "JF"
  949. } else {
  950. SupplierTypeCode = ""
  951. }
  952. destZipName := SupplierName + time.Now().Format("20060102") + SupplierTypeCode
  953. destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
  954. err := Compress(files, destZip)
  955. retDocUrl := ""
  956. if err == nil {
  957. var sw *Seaweed
  958. var filer []string
  959. if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
  960. filer = []string{_filer}
  961. }
  962. sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
  963. _, _, fID, _ := sw.UploadFile(destZip, "", "")
  964. retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
  965. }
  966. os.Remove(destZip)
  967. // os.RemoveAll(_dir)
  968. errinfo.Code = 0
  969. errinfo.Item = retDocUrl
  970. this.Data["json"] = &errinfo
  971. this.ServeJSON()
  972. }
  973. func Compress(files []*os.File, dest string) error {
  974. d, _ := os.Create(dest)
  975. defer d.Close()
  976. w := zip.NewWriter(d)
  977. defer w.Close()
  978. for _, file := range files {
  979. err := compress(file, "", w)
  980. if err != nil {
  981. return err
  982. }
  983. }
  984. return nil
  985. }
  986. func compress(file *os.File, prefix string, zw *zip.Writer) error {
  987. info, err := file.Stat()
  988. if err != nil {
  989. return err
  990. }
  991. if info.IsDir() {
  992. prefix = prefix + "/" + info.Name()
  993. fileInfos, err := file.Readdir(-1)
  994. if err != nil {
  995. return err
  996. }
  997. for _, fi := range fileInfos {
  998. f, err := os.Open(file.Name() + "/" + fi.Name())
  999. if err != nil {
  1000. return err
  1001. }
  1002. err = compress(f, prefix, zw)
  1003. if err != nil {
  1004. return err
  1005. }
  1006. }
  1007. } else {
  1008. header, err := zip.FileInfoHeader(info)
  1009. header.Name = prefix + "/" + header.Name
  1010. if err != nil {
  1011. return err
  1012. }
  1013. writer, err := zw.CreateHeader(header)
  1014. if err != nil {
  1015. return err
  1016. }
  1017. _, err = io.Copy(writer, file)
  1018. file.Close()
  1019. if err != nil {
  1020. return err
  1021. }
  1022. }
  1023. return nil
  1024. }
  1025. // @Title 获取资质列表
  1026. // @Description get user by tokenaddsubfile
  1027. // @Success 200 {object} models.Userblood
  1028. // @router /gettableheaderlist [get]
  1029. func (this *SelectController) GetTableHeaderList() {
  1030. typeCode := this.GetString("Type")
  1031. var tableHeader []tableheader.BaseTableheader
  1032. svc := tableheader.GetTableHeaderService(utils.DBE)
  1033. where := "CategoryCode='" + typeCode + "'"
  1034. svc.GetEntitysByWhere(BaseTableHeader, where, &tableHeader)
  1035. var errinfo ErrorDataInfo
  1036. errinfo.Code = 0
  1037. errinfo.Item = tableHeader
  1038. this.Data["json"] = &errinfo
  1039. this.ServeJSON()
  1040. }