package oilsupplier import ( "archive/zip" "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub" "encoding/json" "fmt" "github.com/tealeg/xlsx" "io" "log" "os" "sort" "strconv" "strings" "time" "dashoo.cn/backend/api/business/oilsupplier/annualaudit" "dashoo.cn/backend/api/business/oilsupplier/infochange" "dashoo.cn/backend/api/business/oilsupplier/qualchange" "dashoo.cn/backend/api/business/oilsupplier/suppliercert" "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend" "dashoo.cn/backend/api/business/oilsupplier/supplierfile" "dashoo.cn/backend/api/business/oilsupplier/tableheader" "dashoo.cn/backend/api/business/register" // "fmt" "dashoo.cn/backend/api/business/oilsupplier/selectbusiness" "dashoo.cn/backend/api/business/oilsupplier/supplier" . "dashoo.cn/backend/api/controllers" "dashoo.cn/utils" . "github.com/linxGnu/goseaweedfs" ) type SelectController struct { BaseController } type UpSearch struct { FullName string } type UpInfoSearch struct { FullName string SupplierTypeName string HeGe int BuHeGe int ZongShu int Reason string } type Processinfo struct { Id int SupplierId int AccessCardNo string WorkflowId string ProcessKey string SupplierName string SupplierTypeCode string Status string Type string CreateOn time.Time AddinTime time.Time RecUnitName string ContactName string Mobile string } // @Title 获取所有 // @Description // @Success 200 {object} // @router /getcompanylist [post] func (this *SelectController) GetTList() { var model supplier.OilSupplierSelect var model1 supplier.RegCapitalRange //注册资金范围 //var model2 supplier.NeedFileTypeStruct //资质结构体 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") if Order != "" && Prop != "" { orderby = Prop if Order == "desc" { asc = false } } //准入证号 if model.AccessCardNo != "" { where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'" } if model.MgrUnit != "" { where = where + " and a.MgrUnit like '%" + model.MgrUnit + "%'" } //企业名称 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 + "'" } } //包含资质 //if model2.NeedFileType != nil && len(model2.NeedFileType) > 0 { // pararm := "" // for i := 0; i < len(model2.NeedFileType); i++ { // // pararm = pararm + "'" + model2.NeedFileType[i] + "'," // // } // fmt.Println(pararm[0 : len(pararm)-1]) // where = where + " and d.NeedFileType in (" + pararm[0:len(pararm)-1] + ")" //} having := "" CerSubName := strings.Split(model.CerSubName, ",") comma := strings.Contains(model.CerSubName, ",") if comma { CerSubName = strings.Split(model.CerSubName, ",") } else { CerSubName = strings.Split(model.CerSubName, ",") } var Ids supplier.OilCertIds //准入范围 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 + "%' " } svc := selectbusiness.GetSelectService(utils.DBE) var list []supplier.OilSupplierSelect total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName, OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids, model.NeedFileType) var datainfo DataInfo datainfo.Items = list datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title get 导出供方信息表 // @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.MgrUnit != "" { where = where + " and a.MgrUnit like '%" + model.MgrUnit + "%'" } //企业名称 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) // 与表头顺序一一对应 ↓ nilTime := time.Time{} 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, "") } if item.ApplyTime == nilTime { dataArr = append(dataArr, "") } else { 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, "") } dataArr = append(dataArr, item.MgrUnit) 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) if item.SetupTime == nilTime { dataArr = append(dataArr, "") } else { dataArr = append(dataArr, item.SetupTime.Format("2006-01-02 15:04:05")) } dataArr = append(dataArr, item.CheckUnitName) dataArr = append(dataArr, item.FullName) if item.CreateOn == nilTime { dataArr = append(dataArr, "") } else { 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} // @router /getbaseinfo [post] func (this *SelectController) GetBaseInfo() { Spesearch := this.GetString("Spesearch") spesearchs := strings.Split(Spesearch, ",") svc := selectbusiness.GetSelectService(utils.DBE) var infoIntelist []supplier.OilSupplierInte for _, item := range spesearchs { //var supplierinfo supplier.SupplierInfoInte var infoInte supplier.OilSupplierInte where := " where 1 = 1 AND a.SupplierName = '" + item + "'" svc.GetInfoByCompId(where, &infoInte.SupplierInfo) var cert1 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert1) infoInte.SupplierInfo.WZStatus = cert1.InFlag infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02") var cert2 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert2) infoInte.SupplierInfo.JSStatus = cert2.InFlag infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02") var cert3 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert3) infoInte.SupplierInfo.JFStatus = cert3.InFlag infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02") if infoInte.SupplierInfo.SupplierName != "" { //var suplliersup []supplier.OilSupplierCertSubInte where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub) where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub) where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub) } else if item == "" { where = "where SupplierTypeCode='01'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub) where = "where and SupplierTypeCode='02'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub) where = "where SupplierTypeCode='03'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub) } infoIntelist = append(infoIntelist, infoInte) } var datainfo DataInfo datainfo.Items = infoIntelist this.Data["json"] = &datainfo this.ServeJSON() } // @Title 根据分页获取公司信息和准入, // 提供给银行接口的用户名 和 密码:ceshi1, Ceshi111 // @Description // @Success 200 {object} // @router /getinfobypage [post] func (this *SelectController) GetInfoByPage() { page := this.GetString("page") svc := selectbusiness.GetSelectService(utils.DBE) var infoIntelist []supplier.OilSupplierInte intpage, _ := strconv.Atoi(page) for i := (intpage - 1) * 50; i < (intpage * 50); i++ { //var supplierinfo supplier.SupplierInfoInte var infoInte supplier.OilSupplierInte stringi := strconv.Itoa(i) where := " where 1 = 1 limit " + stringi + ",1" svc.GetInfoByCompId(where, &infoInte.SupplierInfo) var cert1 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '01'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert1) infoInte.SupplierInfo.WZStatus = cert1.InFlag infoInte.SupplierInfo.WZDate = cert1.ApplyTime.Format("2006-01-02") var cert2 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '02'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert2) infoInte.SupplierInfo.JSStatus = cert2.InFlag infoInte.SupplierInfo.JSDate = cert2.ApplyTime.Format("2006-01-02") var cert3 suppliercert.OilSupplierCert where = "SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode= '03'" svc.GetEntityByWhere(OilSupplierCertName, where, &cert3) infoInte.SupplierInfo.JFStatus = cert3.InFlag infoInte.SupplierInfo.JFDate = cert3.ApplyTime.Format("2006-01-02") if infoInte.SupplierInfo.SupplierName != "" { where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='01'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.WZsub) where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='02'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JSsub) where = "where SupplierId=" + strconv.Itoa(infoInte.SupplierInfo.Id) + " and SupplierTypeCode='03'" svc.Getoilsuppliercertsub(OilSupplierCertSubName, where, &infoInte.JFsub) } if infoInte.SupplierInfo.Id != 0 { infoIntelist = append(infoIntelist, infoInte) } } var datainfo DataInfo datainfo.Items = infoIntelist this.Data["json"] = &datainfo this.ServeJSON() } // @Title 获取所有 // @Description // @Success 200 {object} // @router /up [post] func (this *SelectController) Up() { var model UpSearch var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) // //获取分页信息 page := this.GetPageInfoForm() where := "" asc := false Order := this.GetString("Order") Prop := this.GetString("Prop") CreateOn := this.GetString("CreateOn") if Order != "" && Prop != "" { if Order == "asc" { asc = true } } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'" } } if model.FullName != "" { where = where + " and (select FullName from Base_Organize where Id = a.CommitComId) like '%" + model.FullName + "%'" } svc := selectbusiness.GetSelectService(utils.DBE) var list []UpInfoSearch total := svc.GetUp(OilSupplierCertName, page.CurrentPage, page.Size, Prop, asc, &list, where) var datainfo DataInfo datainfo.Items = list datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title 获取所有资质名称 // @Description // @Success 200 {object} // @router /getnftoptions [post] func (this *SelectController) GetNFTOptions() { svc := selectbusiness.GetSelectService(utils.DBE) var list []map[string]string sql := "select distinct(Name) from " + BaseTableHeader + "" list, _ = svc.DBE.QueryString(sql) var datainfo DataInfo datainfo.Items = list this.Data["json"] = &datainfo this.ServeJSON() } // @Title 流程查询准入 // @Description // @Success 200 {object} // @router /getprocessauditlist [get] func (this *SelectController) GetProcessAuditList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 and b.WorkflowId != '' and b.WorkflowId != '0' " orderby := "Id" asc := false Order := this.GetString("Order") Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } } svc := supplier.GetOilSupplierService(utils.DBE) tabinx := this.GetString("tabinx") supplierTypeCode := this.GetString("SupplierTypeCode") supplierName := this.GetString("SupplierName") CreateOn := this.GetString("CreateOn") //企业用户必须加创建人条件 var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 " svc.GetEntity(®isterUser, sql) var processinfolist []Processinfo if this.User.IsCompanyUser == 1 { where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')" } if supplierTypeCode != "" { where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'" } if supplierName != "" { where = where + " and a.SupplierName like '%" + supplierName + "%'" } var total int64 = 0 var datainfo DataInfo if tabinx == "1" || tabinx == "0" { var list []Processinfo //[]supplier.OilSupplierView if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'" } } total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, "b.Id", asc, &list, where) processinfolist = append(processinfolist, list...) //datainfo.Items = processinfolist } if tabinx == "2" || tabinx == "0" { whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'" //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'" } if supplierTypeCode != "" { whereapp = whereapp + " and a.AppendType = '" + supplierTypeCode + "'" } if supplierName != "" { whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] whereapp = whereapp + " a.and CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'" } } var list []Processinfo //[]suppliercertappend.OilSupplierCertAppend svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) total = total + svc.GetProcessInfoWithOrderBytbl(OilSupplierCertAppendName, page.CurrentPage, page.Size, "a.Id", asc, &list, whereapp) processinfolist = append(processinfolist, list...) //datainfo.Items = processinfolist } if tabinx == "3" || tabinx == "0" { whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'" //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'" } if supplierTypeCode != "" { whereapp = whereapp + " and a.SupplierTypeName = '" + supplierTypeCode + "'" } if supplierName != "" { whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'" } } var list []Processinfo //[]annualaudit.OilAnnualAudit svc := annualaudit.GetOilAnnualAuditService(utils.DBE) total = total + svc.GetProcessInfoWithOrderBytbl(OilAnnualAuditName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp) processinfolist = append(processinfolist, list...) //datainfo.Items = processinfolist } if tabinx == "4" || tabinx == "0" { whereapp := "1=1 and a.WorkflowId != '' and a.WorkflowId != '0'" //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'" } if supplierName != "" { whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] whereapp = whereapp + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'" } } var list []Processinfo //[]infochange.OilInfoChange svc := infochange.GetInfoChangeService(utils.DBE) total = total + svc.GetProcessInfoWithOrderBytbl(OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, whereapp) processinfolist = append(processinfolist, list...) //datainfo.Items = processinfolist } if tabinx == "5" { whereapp := "1=1 and WorkflowId != '' and WorkflowId != '0'" //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'" } if supplierName != "" { whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'" } } svc := qualchange.GetQualChangeService(utils.DBE) var list []qualchange.OilQualChangeMain total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp) datainfo.Items = list } if tabinx == "0" { whereapp := "1=1 and WorkflowId != '' and WorkflowId != '0'" where1 := "1=1 and WorkflowId != '' and WorkflowId != '0'" where2 := "1=1 and WorkflowId != '' and WorkflowId != '0'" where3 := "1=1 and WorkflowId != '' and WorkflowId != '0'" //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'" where1 = where1 + " and a.CreateUserId = '" + this.User.Id + "'" where2 = where2 + " and a.CreateUserId = '" + this.User.Id + "'" where3 = where3 + " and a.CreateUserId = '" + this.User.Id + "'" } if supplierTypeCode != "" { //whereapp = whereapp + " and a.SupplierTypeCode = '" + supplierTypeCode + "'" where1 = where1 + " and b.SupplierTypeCode = '" + supplierTypeCode + "'" where2 = where2 + " and a.AppendType = '" + supplierTypeCode + "'" where3 = where3 + " and a.SupplierTypeName = '" + supplierTypeCode + "'" } if supplierName != "" { whereapp = whereapp + " and a.SupplierName like '%" + supplierName + "%'" where1 = where1 + " and a.SupplierName like '%" + supplierName + "%'" where2 = where2 + " and a.SupplierName like '%" + supplierName + "%'" where3 = where3 + " and a.SupplierName like '%" + supplierName + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] whereapp = whereapp + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'" } } svc := annualaudit.GetOilAnnualAuditService(utils.DBE) var list []Processinfo svc.GetProcessInfoAllWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, whereapp, where1, where2, where3) processinfolist = list } sort.Slice(processinfolist, func(i, j int) bool { return processinfolist[i].CreateOn.Unix() > processinfolist[j].CreateOn.Unix() }) datainfo.Items = processinfolist datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title 准入范围查询 // @Description // @Success 200 {object} // @router /zrfwselect [get] func (this *SelectController) ZrfwSelect() { //获取分页信息 page := this.GetPageInfoForm() limitCurrent := (page.CurrentPage - 1) * page.Size svc := selectbusiness.GetSelectService(utils.DBE) supplierTypeCode := this.GetString("SupplierTypeCode") certsub := this.GetString("certsub") //企业用户必须加创建人条件 var registerUser register.OilCorporateInfo var company supplier.OilSupplier sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 " svc.GetEntity(®isterUser, sql) if this.User.IsCompanyUser == 1 { sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'" svc.GetEntity(&company, sql1) } where := "" if certsub != "" { where = " and (Code like '%" + certsub + "%' or Name like '%" + certsub + "%')" } if company.SupplierName != "" { 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) + "" result, _ := svc.DBE.QueryString(sql2) sql3 := "select count(distinct(Code)) total from OilSupplierCertSub where SupplierId='" + strconv.Itoa(company.Id) + "' and SupplierTypeCode='" + supplierTypeCode + "'" + where result1, _ := svc.DBE.QueryString(sql3) total, _ := strconv.ParseInt(result1[0]["total"], 10, 64) var datainfo DataInfo datainfo.Items = result datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } else { var datainfo DataInfo datainfo.Items = "" datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } } // @Title 获取所有 // @Description // @Success 200 {object} // @router /getallbusinesslist [post] func (this *SelectController) GetAllBusinesList() { perject := this.GetString("Perject") accessCardNo := this.GetString("AccessCardNo") supplierTypeCode := this.GetString("SupplierTypeCode") supplierName := this.GetString("SupplierName") var list []selectbusiness.SelectBusiness // 准入 if perject == "1" || perject == "" { where := "1=1 " if accessCardNo != "" { where = where + " and b.AccessCardNo='" + accessCardNo + "'" } if supplierTypeCode != "" { where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'" } if supplierName != "" { where = where + " and a.SupplierName like '%" + supplierName + "%'" } var zrlist []supplier.OilSupplierView zrsvc := supplier.GetOilSupplierService(utils.DBE) if this.User.IsCompanyUser == 1 { var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 " zrsvc.GetEntity(®isterUser, sql) where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')" } zrwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'" zrsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 100, "b.Id", false, &zrlist, zrwhere) for _, item := range zrlist { var sele selectbusiness.SelectBusiness sele.SupplierName = item.SupplierName sele.CreateOn = item.CreateOn sele.AccessCardNo = item.AccessCardNo sele.TypeCode = item.SupplierTypeCode sele.TypeName = item.SupplierTypeName sele.Preject = "1" list = append(list, sele) } } // 增项 if perject == "2" || perject == "" { where := "1=1 " if accessCardNo != "" { where = where + " and b.AccessCardNo='" + accessCardNo + "'" } if supplierTypeCode != "" { where = where + " and b.AppendType='" + supplierTypeCode + "'" } if supplierName != "" { where = where + " and a.SupplierName like '%" + supplierName + "%'" } var zxlist []suppliercertappend.OilSupplierCertAppend zxsvc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) if this.User.IsCompanyUser == 1 { var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "' and CheckStatus = 11 " zxsvc.GetEntity(®isterUser, sql) where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')" } zxwhere := where + " and b.Status='" + suppliercert.STORE_STATUS + "'" zxsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, 1, 100, "b.Id", false, &zxlist, zxwhere) for _, item := range zxlist { var sele selectbusiness.SelectBusiness sele.SupplierName = item.SupplierName sele.CreateOn = item.CreateOn sele.AccessCardNo = item.AccessCardNo sele.TypeCode = item.AppendType sele.TypeName = "" sele.Preject = "2" list = append(list, sele) } } // 年审 if perject == "3" || perject == "" { where := "1=1 " if accessCardNo != "" { where = where + " and b.AccessCardNo='" + accessCardNo + "'" } if supplierTypeCode != "" { where = where + " and b.SupplierTypeName='" + supplierTypeCode + "'" } if supplierName != "" { where = where + " and a.SupplierName like '%" + supplierName + "%'" } var nslist []annualaudit.OilAnnualAudit nssvc := annualaudit.GetOilAnnualAuditService(utils.DBE) if this.User.IsCompanyUser == 1 { var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "' and CheckStatus = 11" nssvc.GetEntity(®isterUser, sql) where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')" } zswhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'" nssvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilAnnualAuditName, 1, 100, "b.Id", false, &nslist, zswhere) for _, item := range nslist { var sele selectbusiness.SelectBusiness sele.SupplierName = item.SupplierName sele.CreateOn = item.CreateOn sele.AccessCardNo = item.AccessCardNo sele.TypeCode = item.SupplierTypeName sele.TypeName = "" sele.Preject = "3" list = append(list, sele) } } // 变更申请 if perject == "4" || perject == "" { where := "1=1 " if accessCardNo != "" { where = where + " and b.AccessCardNo='" + accessCardNo + "'" } if supplierTypeCode != "" { where = where + " and b.SupplierTypeCode='" + supplierTypeCode + "'" } if supplierName != "" { where = where + " and a.SupplierName like '%" + supplierName + "%'" } var bglist []infochange.SuppModelInfo bgsvc := infochange.GetInfoChangeService(utils.DBE) if this.User.IsCompanyUser == 1 { var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "' and CheckStatus = 11" bgsvc.GetEntity(®isterUser, sql) where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')" } bgwhere := where + " and b.Status='" + suppliercert.DRAFT_STATUS + "'" bgsvc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, 1, 100, "b.Id", false, &bglist, bgwhere) for _, item := range bglist { var sele selectbusiness.SelectBusiness sele.SupplierName = item.SupplierName sele.CreateOn = item.CreateOn sele.AccessCardNo = "" sele.TypeCode = item.SupplierTypeCode sele.TypeName = item.SupplierTypeName sele.Preject = "4" list = append(list, sele) } } var datainfo DataInfo datainfo.Items = list this.Data["json"] = &datainfo this.ServeJSON() } // @Title 文件上传 // @Description get user by tokenaddsubfile // @Success 200 {object} models.Userblood // @router /filelist [get] func (this *SelectController) FileList() { page := this.GetPageInfoForm() var list []supplierfile.OilSupplierFile svc := supplierfile.GetSupplierfileService(utils.DBE) where := " 1=1" orderby := "SupplierTypeCode" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") subfilename := this.GetString("subfileName") supplierId := this.GetString("SupplierId") createOn := this.GetString("CreateOn") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } } //企业用户必须加创建人条件 var registerUser register.OilCorporateInfo var company supplier.OilSupplier sql := " UserName='" + this.User.Username + "' and CheckStatus = 11" svc.GetEntity(®isterUser, sql) sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'" svc.GetEntity(&company, sql1) if supplierId != "0" { where = where + " and SupplierId=" + supplierId } else { where = where + " and SupplierId=" + strconv.Itoa(company.Id) } if subfilename != "" { where = where + " and NeedFileType like '%" + subfilename + "%'" } if createOn != "" { dates := strings.Split(createOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] where = where + " and EffectDate>='" + minDate + "' and EffectDate<='" + maxDate + "'" } } where = where + " and IsDelete = 0 and SupType not in (2, 4) " total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where) var datainfo DataInfo datainfo.Items = list datainfo.CurrentItemCount = total this.Data["json"] = &datainfo this.ServeJSON() } // @Title 获取列表 // @Description // @Success 200 {object} // @router /totallist [get] func (this *SelectController) GetTotalList() { //获取分页信息 page := this.GetPageInfoForm() where := "0" orderby := "Id" asc := false Order := this.GetString("Order") Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } } Years := this.GetString("Years") if Years != "" { where = Years } //CreateOn := this.GetString("CreateOn") // //if CreateOn != "" { // dates := strings.Split(CreateOn, ",") // if len(dates) == 2 { // minDate := dates[0] // maxDate := dates[1] // where = where + " and ValidityTo>='" + minDate + "' and ValidityTo<='" + maxDate + "'" // } //} svc := selectbusiness.GetSelectService(utils.DBE) var list []selectbusiness.TotalCount svc.GetTotalInMonth(orderby, asc, &list, where) var datainfo DataInfo datainfo.Items = list datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title 导出资质图片 // @Description // @Success 200 {object} // @router /getallbusinesslicense [get] func (this *SelectController) GetAllBusinessLicense() { needFileType := this.GetString("NeedFileType") svc := supplier.GetOilSupplierService(utils.DBE) var supplierList []supplier.OilSupplier where := "1=1" svc.GetEntities(&supplierList, where) _dir := utils.Cfg.MustValue("file", "tmplateDir") + needFileType downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP") for _, item := range supplierList { var supplierFile supplierfile.OilSupplierFile where := "SupplierId=" + strconv.Itoa(item.Id) + " and NeedFileType='" + needFileType + "'" has := svc.GetEntity(&supplierFile, where) if has { fileArr := strings.Split(supplierFile.FileName, ".") fileUrl := strings.Split(supplierFile.FileUrl, "|") if len(fileUrl) == 2 && len(fileArr) == 2 { utils.DownloadFile(downFileUrl+fileUrl[0], item.SupplierName+"."+fileArr[1], _dir) } } } //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip") f1, _ := os.Open(_dir) var files = []*os.File{f1} //destZipName := time.Now().Format("2006-01-02") destZipName := needFileType destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip" err := Compress(files, destZip) retDocUrl := "" if err == nil { 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(destZip, "", "") retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID } os.Remove(destZip) os.RemoveAll(_dir) var errinfo ErrorDataInfo errinfo.Code = 0 errinfo.Item = retDocUrl this.Data["json"] = &errinfo this.ServeJSON() } // @Title 导出企业资质图片 // @Description // @Success 200 {object} // @router /getallbusinesslicensebyid [get] func (this *SelectController) GetBusinessLicenseById() { SupplierId := this.GetString("SupplierId") SupplierName := this.GetString("SupplierName") SupplierTypeCode := this.GetString("SupTypeCode") svc := supplier.GetOilSupplierService(utils.DBE) if SupplierId == "0" && this.User.IsCompanyUser == 1 { var registerUser register.OilCorporateInfo var company supplier.OilSupplier sql := " UserName='" + this.User.Username + "' and CheckStatus = 11" svc.GetEntity(®isterUser, sql) sql1 := " CreateUserId = '" + this.User.Id + "' or CommercialNo='" + registerUser.CommercialNo + "'" svc.GetEntity(&company, sql1) SupplierId = strconv.Itoa(company.Id) SupplierName = company.SupplierName } _dir := utils.Cfg.MustValue("file", "tmplateDir") + SupplierName downFileUrl := "http://" + utils.Cfg.MustValue("server", "localIP") var supplierFile []supplierfile.OilSupplierFile where := "SupplierId=" + SupplierId svc.GetEntities(&supplierFile, where) var errinfo ErrorDataInfo if len(supplierFile) == 0 { errinfo.Code = -1 errinfo.Message = "该公司没有可导出的资质!" this.Data["json"] = &errinfo this.ServeJSON() return } for _, item := range supplierFile { fileArr := strings.Split(item.FileName, ".") fileUrl := strings.Split(item.FileUrl, "|") if len(fileUrl) == 2 && len(fileArr) == 2 { utils.DownloadFile(downFileUrl+fileUrl[0], item.NeedFileType+"."+fileArr[1], _dir) } } //Zip(_dir, utils.Cfg.MustValue("file", "tmplateDir") + "license.zip") f1, _ := os.Open(_dir) var files = []*os.File{f1} if SupplierTypeCode == "01" { SupplierTypeCode = "WZ" } else if SupplierTypeCode == "02" { SupplierTypeCode = "JS" } else if SupplierTypeCode == "03" { SupplierTypeCode = "JF" } else { SupplierTypeCode = "" } destZipName := SupplierName + time.Now().Format("20060102") + SupplierTypeCode destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip" err := Compress(files, destZip) retDocUrl := "" if err == nil { 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(destZip, "", "") retDocUrl = utils.Cfg.MustValue("file", "downFileHost") + "/" + fID } os.Remove(destZip) os.RemoveAll(_dir) errinfo.Code = 0 errinfo.Item = retDocUrl this.Data["json"] = &errinfo this.ServeJSON() } func Compress(files []*os.File, dest string) error { d, _ := os.Create(dest) defer d.Close() w := zip.NewWriter(d) defer w.Close() for _, file := range files { err := compress(file, "", w) if err != nil { return err } } return nil } func compress(file *os.File, prefix string, zw *zip.Writer) error { info, err := file.Stat() if err != nil { return err } if info.IsDir() { prefix = prefix + "/" + info.Name() fileInfos, err := file.Readdir(-1) if err != nil { return err } for _, fi := range fileInfos { f, err := os.Open(file.Name() + "/" + fi.Name()) if err != nil { return err } err = compress(f, prefix, zw) if err != nil { return err } } } else { header, err := zip.FileInfoHeader(info) header.Name = prefix + "/" + header.Name if err != nil { return err } writer, err := zw.CreateHeader(header) if err != nil { return err } _, err = io.Copy(writer, file) file.Close() if err != nil { return err } } return nil } // @Title 获取资质列表 // @Description get user by tokenaddsubfile // @Success 200 {object} models.Userblood // @router /gettableheaderlist [get] func (this *SelectController) GetTableHeaderList() { typeCode := this.GetString("Type") var tableHeader []tableheader.BaseTableheader svc := tableheader.GetTableHeaderService(utils.DBE) where := "CategoryCode='" + typeCode + "'" svc.GetEntitysByWhere(BaseTableHeader, where, &tableHeader) var errinfo ErrorDataInfo errinfo.Code = 0 errinfo.Item = tableHeader this.Data["json"] = &errinfo this.ServeJSON() } // @Title 获取某个公司信息-安全管理平台-对外 // @Description // @Success 200 {object} // @router /getSupplierInfo [get] func (this *SelectController) GetSupplierInfo() { commercialNo := this.GetString("CommercialNo") var errinfo ErrorInfo if commercialNo == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } where := "b.InFlag in (1,2,3) and a.CommercialNo = '" + commercialNo + "'" svc := selectbusiness.GetSelectService(utils.DBE) var suppCertList []supplier.OilSupplierSelect2 svc.GetMyPagingEntitiesWithOrderBytbl2(&suppCertList, where) for i, suppCert := range suppCertList { var fileList []supplierfile.OilSupplierFileSelect where1 := "IsDelete = 0 and SupType not in (2,4) and SupplierId = " + strconv.Itoa(suppCert.Id) + " and SupplierTypeCode in ('000','" + suppCert.SupplierTypeCode + "')" svc.GetFileList(&fileList, where1) for ii, file := range fileList { var fileList1 []supplierfile.OilSupplierFileSelect1 fileArr := strings.Split(file.FileUrl, "$") for _, file1 := range fileArr { var fileList2 supplierfile.OilSupplierFileSelect1 fileArr1 := strings.Split(file1, "|") fileList2.FileUrl = fileArr1[0] fileList2.FileName = fileArr1[1] fileList1 = append(fileList1, fileList2) } fileList[ii].FileList = fileList1 } suppCertList[i].FileList = fileList var subList []suppliercertsub.OilSupplierCertSubSelect where1 = "Type in (1, 3) and SupplierId = " + strconv.Itoa(suppCert.Id) + " and SupplierCertId = " + strconv.Itoa(suppCert.CertId) svc.GetEntitysByWhere(OilSupplierCertSubName, where1, &subList) suppCertList[i].SubList = subList } var datainfo DataInfo datainfo.Items = suppCertList this.Data["json"] = &datainfo this.ServeJSON() }