|
|
@@ -4,7 +4,9 @@ import (
|
|
|
"archive/zip"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
"io"
|
|
|
+ "log"
|
|
|
"os"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
@@ -286,6 +288,326 @@ func (this *SelectController) GetTList() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// @Title get 导出ex
|
|
|
+// @Description
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /export-company-list [post]
|
|
|
+func (this *SelectController) ExportCompanyList() {
|
|
|
+
|
|
|
+ var model supplier.OilSupplierSelect
|
|
|
+ var model1 supplier.RegCapitalRange //注册资金范围
|
|
|
+
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ json.Unmarshal(jsonBlob, &model1)
|
|
|
+ //json.Unmarshal(jsonBlob, &model2)
|
|
|
+
|
|
|
+ // //获取分页信息
|
|
|
+ page := this.GetPageInfoForm()
|
|
|
+ where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' "
|
|
|
+ orderby := "a.Id"
|
|
|
+ asc := true
|
|
|
+ Order := this.GetString("Order")
|
|
|
+ Prop := this.GetString("Prop")
|
|
|
+ OperType := this.GetString("OperType")
|
|
|
+ Grade := this.GetString("Grade")
|
|
|
+ CheckUId := this.GetString("CheckUId")
|
|
|
+ FullId := this.GetString("FullId")
|
|
|
+ selectedCertIdList := this.GetString("selectedCertIdList")
|
|
|
+ if Order != "" && Prop != "" {
|
|
|
+ orderby = Prop
|
|
|
+ if Order == "desc" {
|
|
|
+ asc = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ having := ""
|
|
|
+ var Ids supplier.OilCertIds
|
|
|
+ if selectedCertIdList != "" {
|
|
|
+ where = where + " and b.Id in (" + selectedCertIdList + ") "
|
|
|
+ } else {
|
|
|
+ //准入证号
|
|
|
+ if model.AccessCardNo != "" {
|
|
|
+ where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ //企业名称
|
|
|
+ if model.SupplierName != "" {
|
|
|
+ where = where + " and a.SupplierName like '%" + model.SupplierName + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ if model.OldSupplierName != "" {
|
|
|
+ where = where + " and a.OldSupplierName like '%" + model.OldSupplierName + "%'"
|
|
|
+ }
|
|
|
+ if FullId != "" {
|
|
|
+ where = where + " and f.Id = '" + FullId + "'"
|
|
|
+ }
|
|
|
+ if CheckUId != "" {
|
|
|
+ where = where + " and b.RecUnitId = '" + CheckUId + "'"
|
|
|
+ }
|
|
|
+
|
|
|
+ //准入类别(基建,物资,技术服务)
|
|
|
+ if model.SupplierTypeCode != "" {
|
|
|
+ where = where + " and b.SupplierTypeCode = '" + model.SupplierTypeCode + "'"
|
|
|
+ }
|
|
|
+ //准入标识 1 准入 2 暂停 3取消
|
|
|
+ if model.InFlag != "" {
|
|
|
+ where = where + " and b.InFlag = '" + model.InFlag + "'"
|
|
|
+ }
|
|
|
+ //法人
|
|
|
+ if model.LegalPerson != "" {
|
|
|
+ where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'"
|
|
|
+ }
|
|
|
+ //联系人
|
|
|
+ if model.ContactName != "" {
|
|
|
+ where = where + " and a.ContactName like '%" + model.ContactName + "%'"
|
|
|
+ }
|
|
|
+ //统一社会信用代码
|
|
|
+ if model.CommercialNo != "" {
|
|
|
+ where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'"
|
|
|
+ }
|
|
|
+ //开户银行
|
|
|
+ if model.DepositBank != "" {
|
|
|
+ where = where + " and a.DepositBank like '%" + model.DepositBank + "%'"
|
|
|
+ }
|
|
|
+
|
|
|
+ if OperType == "1" {
|
|
|
+ OperType = "制造商"
|
|
|
+ } else if OperType == "2" {
|
|
|
+ OperType = "代理商"
|
|
|
+ } else if OperType == "3" {
|
|
|
+ OperType = "贸易商"
|
|
|
+ }
|
|
|
+ //准入状态
|
|
|
+ if OperType != "" {
|
|
|
+ where = where + " and a.OperType = '" + OperType + "'"
|
|
|
+ }
|
|
|
+ //级别
|
|
|
+ if Grade != "" {
|
|
|
+ where = where + " and a.Grade = '" + Grade + "'"
|
|
|
+ }
|
|
|
+
|
|
|
+ //HSE审查
|
|
|
+ if model.HseTraining != "" {
|
|
|
+ where = where + " and a.HseTraining = '" + model.HseTraining + "'"
|
|
|
+ }
|
|
|
+ //公司类型
|
|
|
+ if model.CompanyType != "" {
|
|
|
+ where = where + " and a.CompanyType like '%" + model.CompanyType + "%'"
|
|
|
+ }
|
|
|
+ //成立时间
|
|
|
+ SetupTime := this.GetString("SetupTime")
|
|
|
+ if SetupTime != "" {
|
|
|
+ where = where + " and a.SetupTime ='" + SetupTime + "'"
|
|
|
+ }
|
|
|
+ //注册资金范围
|
|
|
+ if model1.RegCapital1 != "" {
|
|
|
+ where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'"
|
|
|
+ }
|
|
|
+ if model1.RegCapital2 != "" {
|
|
|
+ where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'"
|
|
|
+ }
|
|
|
+
|
|
|
+ //注册省份
|
|
|
+ if model.Province != "" {
|
|
|
+ where = where + " and a.Province = '" + model.Province + "'"
|
|
|
+ }
|
|
|
+ //注册市
|
|
|
+ if model.City != "" {
|
|
|
+ where = where + " and a.City = '" + model.City + "'"
|
|
|
+ }
|
|
|
+ //注册区
|
|
|
+ if model.Street != "" {
|
|
|
+ where = where + " and a.Street = '" + model.Street + "'"
|
|
|
+ }
|
|
|
+ //注册详细地址
|
|
|
+ if model.Address != "" {
|
|
|
+ where = where + " and a.Address like '%" + model.Address + "%'"
|
|
|
+ }
|
|
|
+ if model.LinkProvince != "" {
|
|
|
+ where = where + " and a.LinkProvince = '" + model.LinkProvince + "'"
|
|
|
+ }
|
|
|
+ if model.LinkCity != "" {
|
|
|
+ where = where + " and a.LinkCity = '" + model.LinkCity + "'"
|
|
|
+ }
|
|
|
+ if model.LinkStreet != "" {
|
|
|
+ where = where + " and a.LinkStreet = '" + model.LinkStreet + "'"
|
|
|
+ }
|
|
|
+ if model.LinkAddress != "" {
|
|
|
+ where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'"
|
|
|
+ }
|
|
|
+ //营业范围
|
|
|
+ if model.BusinessScope != "" {
|
|
|
+ where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'"
|
|
|
+ }
|
|
|
+ CreateOn := this.GetString("CreateOn")
|
|
|
+ if CreateOn != "" {
|
|
|
+ dates := strings.Split(CreateOn, ",")
|
|
|
+ if len(dates) == 2 {
|
|
|
+ minDate := dates[0]
|
|
|
+ maxDate := dates[1]
|
|
|
+ where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ a := model.InStyle
|
|
|
+ fmt.Println(a)
|
|
|
+ //准入方式
|
|
|
+ if model.InStyle != "" {
|
|
|
+ if model.InStyle == "0" {
|
|
|
+ where = where + " and b.InStyle in ('2','3','4','5')"
|
|
|
+ } else {
|
|
|
+ where = where + " and b.InStyle ='" + model.InStyle + "'"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CerSubName := strings.Split(model.CerSubName, ",")
|
|
|
+ comma := strings.Contains(model.CerSubName, ",")
|
|
|
+
|
|
|
+ if comma {
|
|
|
+ CerSubName = strings.Split(model.CerSubName, ",")
|
|
|
+ } else {
|
|
|
+ CerSubName = strings.Split(model.CerSubName, ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ //准入范围
|
|
|
+ if model.CerSubName != "" {
|
|
|
+ svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ where1 := ""
|
|
|
+ for key, value := range CerSubName {
|
|
|
+ if key == 0 {
|
|
|
+ where1 += " (Name like '%" + value + "%' or Code like '" + value + "%' "
|
|
|
+ } else {
|
|
|
+ where1 += "or Name like '%" + value + "%' or Code like '" + value + "%' "
|
|
|
+ }
|
|
|
+ }
|
|
|
+ where1 += ") "
|
|
|
+ svc.GetCertIds(&Ids, where1)
|
|
|
+ }
|
|
|
+ //资质
|
|
|
+ if model.NeedFileType != "" {
|
|
|
+ having = " having NeedFileType like '%" + model.NeedFileType + "%' "
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ page.Size = 15000
|
|
|
+ svc := selectbusiness.GetSelectService(utils.DBE)
|
|
|
+ var list []supplier.OilSupplierSelect
|
|
|
+
|
|
|
+ total := svc.GetMyPagingEntitiesWithOrderBytblForExport(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
|
|
|
+ OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids, model.NeedFileType)
|
|
|
+ log.Print("共导出供方信息:", total)
|
|
|
+ // 获取到所有符合条件的供方信息列表 ↑
|
|
|
+
|
|
|
+ fileTitle := "供方信息表"
|
|
|
+ //自定义显示列
|
|
|
+ title := strings.Split("企业名称,准入证号,准入类别,准入方式,状态,有效日期,企业曾用名,级别,供应商类型,法人代表,注册资金,联系人,"+
|
|
|
+ "移动电话,统一社会信用代码,开户银行,公司类型,成立时间,推荐单位,专业处室,申请时间,注册地址,通信地址,营业范围,企业资质,备注", ",")
|
|
|
+
|
|
|
+ f := xlsx.NewFile()
|
|
|
+ sheet, _ := f.AddSheet(fileTitle)
|
|
|
+ row := sheet.AddRow()
|
|
|
+ row.WriteSlice(&title, -1)
|
|
|
+
|
|
|
+ // 与表头顺序一一对应 ↓
|
|
|
+ for _, item := range list {
|
|
|
+ var dataArr []string
|
|
|
+ dataArr = append(dataArr, item.SupplierName)
|
|
|
+ dataArr = append(dataArr, item.AccessCardNo)
|
|
|
+ // 准入类别
|
|
|
+ if item.SupplierTypeCode == "01" {
|
|
|
+ dataArr = append(dataArr, "物资类")
|
|
|
+ } else if item.SupplierTypeCode == "02" {
|
|
|
+ dataArr = append(dataArr, "基建类")
|
|
|
+ } else if item.SupplierTypeCode == "03" {
|
|
|
+ dataArr = append(dataArr, "服务类")
|
|
|
+ } else {
|
|
|
+ dataArr = append(dataArr, "")
|
|
|
+ }
|
|
|
+ // 准入方式
|
|
|
+ if item.InStyle == "1" {
|
|
|
+ dataArr = append(dataArr, "评审准入")
|
|
|
+ } else if item.InStyle == "2" {
|
|
|
+ dataArr = append(dataArr, "一级物资备案准入")
|
|
|
+ } else if item.InStyle == "3" {
|
|
|
+ dataArr = append(dataArr, "二级物资备案准入")
|
|
|
+ } else if item.InStyle == "4" {
|
|
|
+ dataArr = append(dataArr, "战略合作准入")
|
|
|
+ } else if item.InStyle == "5" {
|
|
|
+ dataArr = append(dataArr, "内部多元准入")
|
|
|
+ } else if item.InStyle == "6" {
|
|
|
+ dataArr = append(dataArr, "招标准入")
|
|
|
+ } else {
|
|
|
+ dataArr = append(dataArr, "")
|
|
|
+ }
|
|
|
+ // 准入标识
|
|
|
+ if item.InFlag == "1" {
|
|
|
+ dataArr = append(dataArr, "准入")
|
|
|
+ } else if item.InFlag == "2" {
|
|
|
+ dataArr = append(dataArr, "暂停")
|
|
|
+ } else if item.InFlag == "3" {
|
|
|
+ dataArr = append(dataArr, "取消")
|
|
|
+ } else {
|
|
|
+ dataArr = append(dataArr, "")
|
|
|
+ }
|
|
|
+
|
|
|
+ dataArr = append(dataArr, item.ApplyTime.Format("2006-01-02 15:04:05"))
|
|
|
+ dataArr = append(dataArr, item.OldSupplierName)
|
|
|
+ if item.Grade == "1" {
|
|
|
+ dataArr = append(dataArr, "一级")
|
|
|
+ } else if item.Grade == "2" {
|
|
|
+ dataArr = append(dataArr, "二级")
|
|
|
+ } else {
|
|
|
+ dataArr = append(dataArr, "")
|
|
|
+ }
|
|
|
+
|
|
|
+ if item.OperType == "制造商" {
|
|
|
+ dataArr = append(dataArr, item.OperType)
|
|
|
+ } else {
|
|
|
+ dataArr = append(dataArr, "非制造商")
|
|
|
+ }
|
|
|
+ dataArr = append(dataArr, item.LegalPerson)
|
|
|
+ dataArr = append(dataArr, strconv.FormatFloat(item.RegCapital, 'f', 2, 64))
|
|
|
+ dataArr = append(dataArr, item.ContactName)
|
|
|
+ dataArr = append(dataArr, item.Mobile)
|
|
|
+ dataArr = append(dataArr, item.CommercialNo)
|
|
|
+ dataArr = append(dataArr, item.DepositBank)
|
|
|
+ dataArr = append(dataArr, item.CompanyType)
|
|
|
+ dataArr = append(dataArr, item.SetupTime.Format("2006-01-02 15:04:05"))
|
|
|
+ dataArr = append(dataArr, item.CheckUnitName)
|
|
|
+ dataArr = append(dataArr, item.FullName)
|
|
|
+ dataArr = append(dataArr, item.CreateOn.Format("2006-01-02 15:04:05"))
|
|
|
+ dataArr = append(dataArr, item.Address)
|
|
|
+ dataArr = append(dataArr, item.LinkAddress)
|
|
|
+ dataArr = append(dataArr, item.BusinessScope)
|
|
|
+ dataArr = append(dataArr, item.NeedFileType)
|
|
|
+ // dataArr = append(dataArr, item.CerSubName) // 准入编码
|
|
|
+ dataArr = append(dataArr, item.Remark)
|
|
|
+
|
|
|
+ row := sheet.AddRow()
|
|
|
+ row.WriteSlice(&dataArr, -1)
|
|
|
+ }
|
|
|
+ for c, cl := 0, len(sheet.Cols); c < cl; c++ {
|
|
|
+ sheet.Cols[c].Width = 20
|
|
|
+ }
|
|
|
+ dir := "static/file/excel/report/" + this.GetAccode()
|
|
|
+ SaveDirectory(dir)
|
|
|
+ path := dir + "/" + "supplier_export_" + utils.TimeFormat(time.Now(), "20060102") + fileTitle + ".xlsx"
|
|
|
+ f.Save(path)
|
|
|
+ var sw *Seaweed
|
|
|
+ var filer []string
|
|
|
+ if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
|
|
|
+ filer = []string{_filer}
|
|
|
+ }
|
|
|
+ sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
|
|
|
+ _, _, fID, _ := sw.UploadFile(path, "", "")
|
|
|
+
|
|
|
+ retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
|
|
|
+ os.Remove(path)
|
|
|
+ this.Data["json"] = retDocUrl
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
// @Title 根据公司名获取公司信息和准入
|
|
|
// @Description
|
|
|
// @Success 200 {object}
|