| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148 |
- 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")
- Prop := this.GetString("Prop")
- CheckUId := this.GetString("CheckUId")
- FullId := this.GetString("FullId")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "desc" {
- asc = false
- }
- }
- leftjoin := ""
- //准入证号
- 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 OldSupplierName like '%" + model.OldSupplierName + "%'"
- }
- if FullId != "" {
- where = where + " and f.Id = '" + FullId + "'"
- }
- if CheckUId != "" {
- where = where + " and g.CheckUnitId = '" + 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:=""
- //准入范围
- if model.CerSubName!="" {
- having = " having CerSubName like '%"+model.CerSubName+"%' "
- leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
- }
- //资质
- if model.NeedFileType!="" {
- having = " having NeedFileType like '%"+model.NeedFileType+"%' "
- }
- if model.CerSubName!=""&& model.NeedFileType!=""{
- having = " having CerSubName like '%"+model.CerSubName+"%' and NeedFileType like '%"+model.NeedFileType+"%' "
- leftjoin = "left join "+ OilSupplierCertSubName + " d on d.SupplierCertId = b.Id "
- }
- 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, leftjoin)
- 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 根据分页获取公司信息和准入
- // @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)
- 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 like '%" + 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 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 + " 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")
- 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("2006-01-02") + SupplierTypeCode
- destZip := utils.Cfg.MustValue("file", "tmplateDir") + destZipName + ".zip"
- err := Compress(files, destZip)
- fmt.Println("err28==", err)
- 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
- }
- fmt.Println("==retDocWatermarkUrlZZXZ==", retDocUrl)
- err = os.RemoveAll(destZip)
- fmt.Println(err)
- err = os.RemoveAll(_dir)
- fmt.Println(err)
- 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()
- }
|