| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- package oilsupplier
- import (
- "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/register"
- "encoding/json"
- "fmt"
- "strconv"
- // "fmt"
- "dashoo.cn/backend/api/business/oilsupplier/selectbusiness"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type SelectController struct {
- BaseController
- }
- type UpSearch struct {
- FullName string
- }
- type UpInfoSearch struct {
- FullName string
- SupplierTypeName string
- HeGe int
- BuHeGe int
- ZongShu int
- Reason 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 "
- orderby := "a.Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- 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 OldSupplierName like '%" + model.OldSupplierName + "%'"
- }
- //准入类别(基建,物资,技术服务)
- 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 + "%'"
- }
- 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+"%' "
- }
- //资质
- 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+"%' "
- }
- svc := selectbusiness.GetSelectService(utils.DBE)
- var list []supplier.OilSupplierSelect
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName,OilSupplierCert2FileName , page.CurrentPage, page.Size, orderby, asc, &list, where,having)
- 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 /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")
- if Order != "" && Prop != "" {
- if Order == "asc" {
- asc = true
- }
- }
- 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")
- //企业用户必须加创建人条件
- var registerUser register.OilCorporateInfo
- sql := " UserName='" + this.User.Username + "'"
- svc.GetEntity(®isterUser,sql)
- 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 == "0" {
- var list []supplier.OilSupplierView
- total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- datainfo.Items = list
- } else if tabinx == "1" {
- whereapp := "1=1"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
- }
- if supplierTypeCode != "" {
- whereapp = whereapp + " and AppendType like '%" + supplierTypeCode + "%'"
- }
- if supplierName != "" {
- whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
- }
- var list []suppliercertappend.OilSupplierCertAppend
- svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
- total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
- datainfo.Items = list
- } else if tabinx == "2" {
- whereapp := "1=1"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
- }
- if supplierTypeCode != "" {
- whereapp = whereapp + " and SupplierTypeName like '%" + supplierTypeCode + "%'"
- }
- if supplierName != "" {
- whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
- }
- var list []annualaudit.OilAnnualAudit
- svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
- total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
- datainfo.Items = list
- } else if tabinx == "3" {
- whereapp := "1=1"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
- }
- if supplierName != "" {
- whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
- }
- var list []infochange.OilInfoChange
- svc := infochange.GetInfoChangeService(utils.DBE)
- total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
- datainfo.Items = list
- } else if tabinx == "4" {
- whereapp := "1=1"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- whereapp = whereapp + " and CreateUserId = '" + this.User.Id + "'"
- }
- if supplierName != "" {
- whereapp = whereapp + " and SupplierName like '%" + supplierName + "%'"
- }
- svc := qualchange.GetQualChangeService(utils.DBE)
- var list []qualchange.OilQualChangeMain
- total = svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, whereapp)
- 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 /zrfwselect [get]
- func (this *SelectController) ZrfwSelect() {
- //获取分页信息
- page := this.GetPageInfoForm()
- limitCurrent:=(page.CurrentPage-1)*page.Size
- svc := selectbusiness.GetSelectService(utils.DBE)
- supplierTypeCode := this.GetString("SupplierTypeCode")
- //企业用户必须加创建人条件
- 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)
- }
- if company.SupplierName!=""{
- sql2:="select distinct(Code),Name,SupplierId from OilSupplierCert2File where SupplierId='"+strconv.Itoa(company.Id)+"' and SupplierTypeCode='"+supplierTypeCode+"' order by Code limit "+strconv.FormatInt(limitCurrent,10)+","+strconv.FormatInt(page.Size,10)+""
- result,_:=svc.DBE.QueryString(sql2)
- sql3:="select count(distinct(Code)) total from OilSupplierCert2File where SupplierId='"+strconv.Itoa(company.Id)+"' and SupplierTypeCode='"+supplierTypeCode+"'"
- 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()
- }
|