| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162 |
- package oilsupplier
- import (
- "archive/zip"
- "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"
- "encoding/json"
- "fmt"
- "io"
- "os"
- "sort"
- "strconv"
- "strings"
- "time"
- // "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
- 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")
- InFlag := this.GetString("InFlag")
- Prop := this.GetString("Prop")
- 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 InFlag != "" {
- where = where + " and b.InFlag = " + InFlag
- }
- //企业名称
- 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 + "%'"
- }
- //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 根据公司名获取公司信息和准入
- // @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 "
- 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 + "'"
- 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"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- whereapp = whereapp + " and a.CreateUserId = '" + this.User.Id + "'"
- }
- if supplierTypeCode != "" {
- whereapp = whereapp + " and a.AppendType like '%" + 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"
- //企业用户必须加创建人条件
- 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"
- //企业用户必须加创建人条件
- 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"
- //企业用户必须加创建人条件
- 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
- }
- 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 + "'"
- 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 + "'"
- 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 + "'"
- 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 + "'"
- 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 + "'"
- 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 := "Id"
- 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 + "'"
- 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 + "'"
- 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()
- }
|