| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601 |
- 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.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.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, "")
- }
- 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 + "'"
- }
- }
- 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 := "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 := "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 = "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()
- }
|