| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
- "dashoo.cn/backend/api/business/oilsupplier/supplierscenefile"
- "dashoo.cn/backend/api/business/register"
- "encoding/json"
- "fmt"
- "github.com/tealeg/xlsx"
- "log"
- "os"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/auditsetting"
- "dashoo.cn/backend/api/business/organize"
- "dashoo.cn/business2/permission"
- "dashoo.cn/backend/api/business/workflow"
- "dashoo.cn/business2/areajson"
- "dashoo.cn/business2/items"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- "github.com/go-xorm/xorm"
- )
- type OilSupplierController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /list [get]
- func (this *OilSupplierController) GetEntityList() {
- //获取分页信息
- 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
- }
- }
- Id := this.GetString("Id")
- SupplierName := this.GetString("SupplierName")
- OilCertificateNo := this.GetString("OilCertificateNo")
- Grade := this.GetString("Grade")
- MgrUnit := this.GetString("MgrUnit")
- OperType := this.GetString("OperType")
- Country := this.GetString("Country")
- MaunAgent := this.GetString("MaunAgent")
- ConstructTeam := this.GetString("ConstructTeam")
- CommercialNo := this.GetString("CommercialNo")
- OrganCode := this.GetString("OrganCode")
- CountryTaxNo := this.GetString("CountryTaxNo")
- LocalTaxNo := this.GetString("LocalTaxNo")
- Address := this.GetString("Address")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- HouseNo := this.GetString("HouseNo")
- ZipCode := this.GetString("ZipCode")
- QualitySystemCert := this.GetString("QualitySystemCert")
- ProductQualityCert := this.GetString("ProductQualityCert")
- MaunLicense := this.GetString("MaunLicense")
- QualifCert := this.GetString("QualifCert")
- QualifCertLevel := this.GetString("QualifCertLevel")
- SafetyLicense := this.GetString("SafetyLicense")
- TechServiceLic := this.GetString("TechServiceLic")
- TJInNotify := this.GetString("TJInNotify")
- SpecIndustryCert := this.GetString("SpecIndustryCert")
- LegalPerson := this.GetString("LegalPerson")
- CategoryCode := this.GetString("CategoryCode")
- CategoryName := this.GetString("CategoryName")
- RegCapital := this.GetString("RegCapital")
- Currency := this.GetString("Currency")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- DepositBank := this.GetString("DepositBank")
- BankAccount := this.GetString("BankAccount")
- EMail := this.GetString("EMail")
- BankCreditRating := this.GetString("BankCreditRating")
- Mobile := this.GetString("Mobile")
- Telphone := this.GetString("Telphone")
- Fax := this.GetString("Fax")
- CompanyTel := this.GetString("CompanyTel")
- QQ := this.GetString("QQ")
- CompanyUrl := this.GetString("CompanyUrl")
- SpecSupplier := this.GetString("SpecSupplier")
- SpecTypeCode := this.GetString("SpecTypeCode")
- SpecTypeName := this.GetString("SpecTypeName")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if OilCertificateNo != "" {
- where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
- }
- if Grade != "" {
- where = where + " and Grade like '%" + Grade + "%'"
- }
- if MgrUnit != "" {
- where = where + " and MgrUnit like '%" + MgrUnit + "%'"
- }
- if OperType != "" {
- where = where + " and OperType like '%" + OperType + "%'"
- }
- if Country != "" {
- where = where + " and Country like '%" + Country + "%'"
- }
- if MaunAgent != "" {
- where = where + " and MaunAgent like '%" + MaunAgent + "%'"
- }
- if ConstructTeam != "" {
- where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
- }
- if CommercialNo != "" {
- where = where + " and CommercialNo like '%" + CommercialNo + "%'"
- }
- if OrganCode != "" {
- where = where + " and OrganCode like '%" + OrganCode + "%'"
- }
- if CountryTaxNo != "" {
- where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
- }
- if LocalTaxNo != "" {
- where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
- }
- if Address != "" {
- where = where + " and Address like '%" + Address + "%'"
- }
- if Province != "" {
- where = where + " and Province like '%" + Province + "%'"
- }
- if City != "" {
- where = where + " and City like '%" + City + "%'"
- }
- if Street != "" {
- where = where + " and Street like '%" + Street + "%'"
- }
- if HouseNo != "" {
- where = where + " and HouseNo like '%" + HouseNo + "%'"
- }
- if ZipCode != "" {
- where = where + " and ZipCode like '%" + ZipCode + "%'"
- }
- if QualitySystemCert != "" {
- where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
- }
- if ProductQualityCert != "" {
- where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
- }
- if MaunLicense != "" {
- where = where + " and MaunLicense like '%" + MaunLicense + "%'"
- }
- if QualifCert != "" {
- where = where + " and QualifCert like '%" + QualifCert + "%'"
- }
- if QualifCertLevel != "" {
- where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
- }
- if SafetyLicense != "" {
- where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
- }
- if TechServiceLic != "" {
- where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
- }
- if TJInNotify != "" {
- where = where + " and TJInNotify like '%" + TJInNotify + "%'"
- }
- if SpecIndustryCert != "" {
- where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
- }
- if LegalPerson != "" {
- where = where + " and LegalPerson like '%" + LegalPerson + "%'"
- }
- if CategoryCode != "" {
- where = where + " and CategoryCode like '%" + CategoryCode + "%'"
- }
- if CategoryName != "" {
- where = where + " and CategoryName like '%" + CategoryName + "%'"
- }
- if RegCapital != "" {
- where = where + " and RegCapital like '%" + RegCapital + "%'"
- }
- if Currency != "" {
- where = where + " and Currency like '%" + Currency + "%'"
- }
- if ContactName != "" {
- where = where + " and ContactName like '%" + ContactName + "%'"
- }
- if CompanyType != "" {
- where = where + " and CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and SetupTime like '%" + SetupTime + "%'"
- }
- if DepositBank != "" {
- where = where + " and DepositBank like '%" + DepositBank + "%'"
- }
- if BankAccount != "" {
- where = where + " and BankAccount like '%" + BankAccount + "%'"
- }
- if EMail != "" {
- where = where + " and EMail like '%" + EMail + "%'"
- }
- if BankCreditRating != "" {
- where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
- }
- if Mobile != "" {
- where = where + " and Mobile like '%" + Mobile + "%'"
- }
- if Telphone != "" {
- where = where + " and Telphone like '%" + Telphone + "%'"
- }
- if Fax != "" {
- where = where + " and Fax like '%" + Fax + "%'"
- }
- if CompanyTel != "" {
- where = where + " and CompanyTel like '%" + CompanyTel + "%'"
- }
- if QQ != "" {
- where = where + " and QQ like '%" + QQ + "%'"
- }
- if CompanyUrl != "" {
- where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
- }
- if SpecSupplier != "" {
- where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
- }
- if SpecTypeName != "" {
- where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- 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 this.User.IsCompanyUser == 1 {
- where = where + " and CreateUserId = '" + this.User.Id + "'"
- } else {
- //超级管理员和有查看所有数据权限的用户不加条件
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
- if !svcPerm.IsAdmin(this.User.Id) && !isauth {
- where = where + " and CreateUserId = '" + this.User.Id + "'"
- }
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var list []supplier.OilSupplier
- total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, 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 get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /certlist [get]
- func (this *OilSupplierController) GetJoinCertEntityList() {
- //获取分页信息
- 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
- }
- }
- SupplierName := this.GetString("SupplierName")
- SupplierTypeName := this.GetString("SupplierTypeName")
- CreateOn := this.GetString("CreateOn")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- OperType := this.GetString("OperType")
- SpecTypeCode := this.GetString("SpecTypeCode")
- Country := this.GetString("Country")
- InStyle := this.GetString("InStyle")
- MgrUnit := this.GetString("MgrUnit")
- PACNumber := this.GetString("PACNumber")
- CommercialNo := this.GetString("CommercialNo")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- Address := this.GetString("Address")
- LinkProvince := this.GetString("LinkProvince")
- LinkCity := this.GetString("LinkCity")
- LinkStreet := this.GetString("LinkStreet")
- LinkAddress := this.GetString("LinkAddress")
- LegalPerson := this.GetString("LegalPerson")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- RegCapital1 := this.GetString("RegCapital1")
- RegCapital2 := this.GetString("RegCapital2")
- BusinessScope := this.GetString("BusinessScope")
- //where = where + " and b.InFlag != '4'"
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- if SupplierTypeName != "" {
- where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- 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 + "'"
- }
- }
- if SupplierTypeCode != "" {
- where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
- }
- if OperType != "" {
- where = where + " and a.OperType like '%" + OperType + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
- }
- if Country != "" {
- where = where + " and a.Country like '%" + Country + "%'"
- }
- if InStyle != "" {
- where = where + " and b.InStyle ='" + InStyle + "'"
- }
- if MgrUnit != "" {
- where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
- }
- if PACNumber != "" {
- where = where + " and a.PACNumber ='" + PACNumber + "'"
- }
- if CommercialNo != "" {
- where = where + " and a.CommercialNo ='" + CommercialNo + "'"
- }
- if Province != "" {
- where = where + " and a.Province ='" + Province + "'"
- }
- if City != "" {
- where = where + " and a.City ='" + City + "'"
- }
- if Street != "" {
- where = where + " and a.Street ='" + Street + "'"
- }
- if Address != "" {
- where = where + " and a.Address ='" + Address + "'"
- }
- if LinkProvince != "" {
- where = where + " and a.LinkProvince ='" + LinkProvince + "'"
- }
- if LinkCity != "" {
- where = where + " and a.LinkCity ='" + LinkCity + "'"
- }
- if LinkStreet != "" {
- where = where + " and a.LinkStreet ='" + LinkStreet + "'"
- }
- if LinkAddress != "" {
- where = where + " and a.LinkAddress ='" + LinkAddress + "'"
- }
- if LegalPerson != "" {
- where = where + " and a.LegalPerson ='" + LegalPerson + "'"
- }
- if ContactName != "" {
- where = where + " and a.ContactName ='" + ContactName + "'"
- }
- if CompanyType != "" {
- where = where + " and a.CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and a.SetupTime ='" + SetupTime + "'"
- }
- //注册资金范围
- if RegCapital1 != "" {
- where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
- }
- if RegCapital2 != "" {
- where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
- }
- if BusinessScope != "" {
- where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
- }
- //企业用户只看自己的数据记录
- /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
- extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
- if extOrganizeId == this.User.DepartmentId {
- where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- }*/
- svc := supplier.GetOilSupplierService(utils.DBE)
- var registerUser register.OilCorporateInfo
- sql := " UserName='" + this.User.Username + "'"
- svc.GetEntity(®isterUser, sql)
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- where = where + " and (a.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
- } else {
- //超级管理员和有查看所有数据权限的用户不加条件
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
- if !svcPerm.IsAdmin(this.User.Id) && !isauth {
- where = where + " and b.CreateUserId = '" + this.User.Id + "'"
- }
- }
- var list []supplier.OilSupplierView
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, 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 get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /jzps_certlist [get]
- func (this *OilSupplierController) GetJZPSJoinCertEntityList() {
- //获取分页信息
- 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
- }
- }
- SupplierName := this.GetString("SupplierName")
- SupplierTypeName := this.GetString("SupplierTypeName")
- CreateOn := this.GetString("CreateOn")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- OperType := this.GetString("OperType")
- SpecTypeCode := this.GetString("SpecTypeCode")
- Country := this.GetString("Country")
- InStyle := this.GetString("InStyle")
- MgrUnit := this.GetString("MgrUnit")
- PACNumber := this.GetString("PACNumber")
- CommercialNo := this.GetString("CommercialNo")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- Address := this.GetString("Address")
- LinkProvince := this.GetString("LinkProvince")
- LinkCity := this.GetString("LinkCity")
- LinkStreet := this.GetString("LinkStreet")
- LinkAddress := this.GetString("LinkAddress")
- LegalPerson := this.GetString("LegalPerson")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- RegCapital1 := this.GetString("RegCapital1")
- RegCapital2 := this.GetString("RegCapital2")
- BusinessScope := this.GetString("BusinessScope")
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- if SupplierTypeName != "" {
- where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- 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 + "'"
- }
- }
- if SupplierTypeCode != "" {
- where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
- }
- if OperType != "" {
- where = where + " and a.OperType like '%" + OperType + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
- }
- if Country != "" {
- where = where + " and a.Country like '%" + Country + "%'"
- }
- if InStyle != "" {
- where = where + " and b.InStyle ='" + InStyle + "'"
- }
- if MgrUnit != "" {
- where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
- }
- if PACNumber != "" {
- where = where + " and a.PACNumber ='" + PACNumber + "'"
- }
- if CommercialNo != "" {
- where = where + " and a.CommercialNo ='" + CommercialNo + "'"
- }
- if Province != "" {
- where = where + " and a.Province ='" + Province + "'"
- }
- if City != "" {
- where = where + " and a.City ='" + City + "'"
- }
- if Street != "" {
- where = where + " and a.Street ='" + Street + "'"
- }
- if Address != "" {
- where = where + " and a.Address ='" + Address + "'"
- }
- if LinkProvince != "" {
- where = where + " and a.LinkProvince ='" + LinkProvince + "'"
- }
- if LinkCity != "" {
- where = where + " and a.LinkCity ='" + LinkCity + "'"
- }
- if LinkStreet != "" {
- where = where + " and a.LinkStreet ='" + LinkStreet + "'"
- }
- if LinkAddress != "" {
- where = where + " and a.LinkAddress ='" + LinkAddress + "'"
- }
- if LegalPerson != "" {
- where = where + " and a.LegalPerson ='" + LegalPerson + "'"
- }
- if ContactName != "" {
- where = where + " and a.ContactName ='" + ContactName + "'"
- }
- if CompanyType != "" {
- where = where + " and a.CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and a.SetupTime ='" + SetupTime + "'"
- }
- //注册资金范围
- if RegCapital1 != "" {
- where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
- }
- if RegCapital2 != "" {
- where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
- }
- if BusinessScope != "" {
- where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
- }
- status := this.GetString("Status")
- if status != "" {
- where = where + " and b.Status='" + status + "'"
- }
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- } else {
- //超级管理员和有查看所有数据权限的用户不加条件
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
- if !svcPerm.IsAdmin(this.User.Id) && !isauth {
- //根据工作流查找
- //集中评审相关人可看数据
- actisvc := workflow.GetActivitiService(utils.DBE)
- //找出待办任务===准入
- var certIdList string
- ids := actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if len(strings.Trim(ids, ",")) > 0 {
- certIdList += strings.Trim(ids, ",") + ","
- }
- ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if len(strings.Trim(ids, ",")) > 0 {
- certIdList += strings.Trim(ids, ",") + ","
- }
- ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if len(strings.Trim(ids, ",")) > 0 {
- certIdList += strings.Trim(ids, ",") + ","
- }
- //ids = actisvc.GetAllMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
- //if len(strings.Trim(ids, ",")) > 0 {
- // certIdList += strings.Trim(ids, ",")+ ","
- //}
- //
- //ids = actisvc.GetAllMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
- //if len(strings.Trim(ids, ",")) > 0 {
- // certIdList += strings.Trim(ids, ",")+ ","
- //}
- //
- //ids = actisvc.GetAllMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
- //if len(strings.Trim(ids, ",")) > 0 {
- // certIdList += strings.Trim(ids, ",")+ ","
- //}
- certIdList = strings.Trim(certIdList, ",")
- certIdarr := strings.Split(certIdList, ",")
- for i, item := range certIdarr {
- idx := strings.Index(item, "-")
- if idx >= 0 {
- certIdarr[i] = strings.Split(item, "-")[0]
- }
- }
- certIdList = strings.Join(certIdarr, ",")
- if certIdList != "" {
- where += " and ( b.Id in (" + certIdList + ")" + " or a.CreateUserId = '" + this.User.Id + "')"
- } else {
- where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- }
- } else {
- //where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- }
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var list []supplier.OilSupplierView
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, 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 get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /storelist [get]
- func (this *OilSupplierController) GetJoinStoreEntityList() {
- //获取分页信息
- 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
- }
- }
- SupplierName := this.GetString("SupplierName")
- SupplierTypeName := this.GetString("SupplierTypeName")
- CreateOn := this.GetString("CreateOn")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- OperType := this.GetString("OperType")
- SpecTypeCode := this.GetString("SpecTypeCode")
- Country := this.GetString("Country")
- InStyle := this.GetString("InStyle")
- MgrUnit := this.GetString("MgrUnit")
- PACNumber := this.GetString("PACNumber")
- CommercialNo := this.GetString("CommercialNo")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- Address := this.GetString("Address")
- LinkProvince := this.GetString("LinkProvince")
- LinkCity := this.GetString("LinkCity")
- LinkStreet := this.GetString("LinkStreet")
- LinkAddress := this.GetString("LinkAddress")
- LegalPerson := this.GetString("LegalPerson")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- RegCapital1 := this.GetString("RegCapital1")
- RegCapital2 := this.GetString("RegCapital2")
- BusinessScope := this.GetString("BusinessScope")
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- if SupplierTypeName != "" {
- where = where + " and b.SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- 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 + "'"
- }
- }
- if SupplierTypeCode != "" {
- where = where + " and b.SupplierTypeCode ='" + SupplierTypeCode + "'"
- }
- if OperType != "" {
- where = where + " and a.OperType like '%" + OperType + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and a.SpecTypeCode = '" + SpecTypeCode + "'"
- }
- if Country != "" {
- where = where + " and a.Country like '%" + Country + "%'"
- }
- if InStyle != "" {
- where = where + " and b.InStyle ='" + InStyle + "'"
- }
- if MgrUnit != "" {
- where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
- }
- if PACNumber != "" {
- where = where + " and a.PACNumber ='" + PACNumber + "'"
- }
- if CommercialNo != "" {
- where = where + " and a.CommercialNo ='" + CommercialNo + "'"
- }
- if Province != "" {
- where = where + " and a.Province ='" + Province + "'"
- }
- if City != "" {
- where = where + " and a.City ='" + City + "'"
- }
- if Street != "" {
- where = where + " and a.Street ='" + Street + "'"
- }
- if Address != "" {
- where = where + " and a.Address ='" + Address + "'"
- }
- if LinkProvince != "" {
- where = where + " and a.LinkProvince ='" + LinkProvince + "'"
- }
- if LinkCity != "" {
- where = where + " and a.LinkCity ='" + LinkCity + "'"
- }
- if LinkStreet != "" {
- where = where + " and a.LinkStreet ='" + LinkStreet + "'"
- }
- if LinkAddress != "" {
- where = where + " and a.LinkAddress ='" + LinkAddress + "'"
- }
- if LegalPerson != "" {
- where = where + " and a.LegalPerson ='" + LegalPerson + "'"
- }
- if ContactName != "" {
- where = where + " and a.ContactName ='" + ContactName + "'"
- }
- if CompanyType != "" {
- where = where + " and a.CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and a.SetupTime ='" + SetupTime + "'"
- }
- //注册资金范围
- if RegCapital1 != "" {
- where = where + " and a.RegCapital >= '" + RegCapital1 + "'"
- }
- if RegCapital2 != "" {
- where = where + " and a.RegCapital <= '" + RegCapital2 + "'"
- }
- if BusinessScope != "" {
- where = where + " and a.BusinessScope like '%" + BusinessScope + "%'"
- }
- status := this.GetString("Status")
- if status != "" {
- where = where + " and b.Status='" + status + "'"
- }
- //企业用户只看自己的数据记录
- /*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
- extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
- if extOrganizeId == this.User.DepartmentId {
- where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- }*/
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- where = where + " and a.CreateUserId = '" + this.User.Id + "'"
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var list []supplier.OilSupplierView
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, 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 get user by token
- // @Success 200 {object} []supplier.OilSupplierView
- // @router /mytasks [get]
- func (this *OilSupplierController) GetMyTaskEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- //Statustype := this.GetString("Statustype")
- //if Statustype != "" {
- // where = " 1=1 and b.Status =" + Statustype
- //}
- where = where + " and b.Status>0"
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierName := this.GetString("SupplierName")
- OilCertificateNo := this.GetString("OilCertificateNo")
- Grade := this.GetString("Grade")
- MgrUnit := this.GetString("MgrUnit")
- OperType := this.GetString("OperType")
- Country := this.GetString("Country")
- MaunAgent := this.GetString("MaunAgent")
- ConstructTeam := this.GetString("ConstructTeam")
- CommercialNo := this.GetString("CommercialNo")
- OrganCode := this.GetString("OrganCode")
- CountryTaxNo := this.GetString("CountryTaxNo")
- LocalTaxNo := this.GetString("LocalTaxNo")
- Address := this.GetString("Address")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- HouseNo := this.GetString("HouseNo")
- ZipCode := this.GetString("ZipCode")
- QualitySystemCert := this.GetString("QualitySystemCert")
- ProductQualityCert := this.GetString("ProductQualityCert")
- MaunLicense := this.GetString("MaunLicense")
- QualifCert := this.GetString("QualifCert")
- QualifCertLevel := this.GetString("QualifCertLevel")
- SafetyLicense := this.GetString("SafetyLicense")
- TechServiceLic := this.GetString("TechServiceLic")
- TJInNotify := this.GetString("TJInNotify")
- SpecIndustryCert := this.GetString("SpecIndustryCert")
- LegalPerson := this.GetString("LegalPerson")
- CategoryCode := this.GetString("CategoryCode")
- CategoryName := this.GetString("CategoryName")
- RegCapital := this.GetString("RegCapital")
- Currency := this.GetString("Currency")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- DepositBank := this.GetString("DepositBank")
- BankAccount := this.GetString("BankAccount")
- EMail := this.GetString("EMail")
- BankCreditRating := this.GetString("BankCreditRating")
- Mobile := this.GetString("Mobile")
- Telphone := this.GetString("Telphone")
- Fax := this.GetString("Fax")
- CompanyTel := this.GetString("CompanyTel")
- QQ := this.GetString("QQ")
- CompanyUrl := this.GetString("CompanyUrl")
- SpecSupplier := this.GetString("SpecSupplier")
- SpecTypeCode := this.GetString("SpecTypeCode")
- SpecTypeName := this.GetString("SpecTypeName")
- Remark := this.GetString("Remark")
- CreateOn := this.GetString("CreateOn")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if Id != "" {
- where = where + " and a.Id like '%" + Id + "%'"
- }
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- if OilCertificateNo != "" {
- where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
- }
- if Grade != "" {
- where = where + " and a.Grade like '%" + Grade + "%'"
- }
- if MgrUnit != "" {
- where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
- }
- if OperType != "" {
- where = where + " and a.OperType like '%" + OperType + "%'"
- }
- if Country != "" {
- where = where + " and a.Country like '%" + Country + "%'"
- }
- if MaunAgent != "" {
- where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
- }
- if ConstructTeam != "" {
- where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
- }
- if CommercialNo != "" {
- where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
- }
- if OrganCode != "" {
- where = where + " and a.OrganCode like '%" + OrganCode + "%'"
- }
- if CountryTaxNo != "" {
- where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
- }
- if LocalTaxNo != "" {
- where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
- }
- if Address != "" {
- where = where + " and a.Address like '%" + Address + "%'"
- }
- if Province != "" {
- where = where + " and a.Province like '%" + Province + "%'"
- }
- if City != "" {
- where = where + " and a.City like '%" + City + "%'"
- }
- if Street != "" {
- where = where + " and a.Street like '%" + Street + "%'"
- }
- if HouseNo != "" {
- where = where + " and a.HouseNo like '%" + HouseNo + "%'"
- }
- if ZipCode != "" {
- where = where + " and a.ZipCode like '%" + ZipCode + "%'"
- }
- if QualitySystemCert != "" {
- where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
- }
- if ProductQualityCert != "" {
- where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
- }
- if MaunLicense != "" {
- where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
- }
- if QualifCert != "" {
- where = where + " and a.QualifCert like '%" + QualifCert + "%'"
- }
- if QualifCertLevel != "" {
- where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
- }
- if SafetyLicense != "" {
- where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
- }
- if TechServiceLic != "" {
- where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
- }
- if TJInNotify != "" {
- where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
- }
- if SpecIndustryCert != "" {
- where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
- }
- if LegalPerson != "" {
- where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
- }
- if CategoryCode != "" {
- where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
- }
- if CategoryName != "" {
- where = where + " and a.CategoryName like '%" + CategoryName + "%'"
- }
- if RegCapital != "" {
- where = where + " and a.RegCapital like '%" + RegCapital + "%'"
- }
- if Currency != "" {
- where = where + " and a.Currency like '%" + Currency + "%'"
- }
- if ContactName != "" {
- where = where + " and a.ContactName like '%" + ContactName + "%'"
- }
- if CompanyType != "" {
- where = where + " and a.CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and a.SetupTime like '%" + SetupTime + "%'"
- }
- if DepositBank != "" {
- where = where + " and a.DepositBank like '%" + DepositBank + "%'"
- }
- if BankAccount != "" {
- where = where + " and a.BankAccount like '%" + BankAccount + "%'"
- }
- if EMail != "" {
- where = where + " and a.EMail like '%" + EMail + "%'"
- }
- if BankCreditRating != "" {
- where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
- }
- if Mobile != "" {
- where = where + " and a.Mobile like '%" + Mobile + "%'"
- }
- if Telphone != "" {
- where = where + " and a.Telphone like '%" + Telphone + "%'"
- }
- if Fax != "" {
- where = where + " and a.Fax like '%" + Fax + "%'"
- }
- if CompanyTel != "" {
- where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
- }
- if QQ != "" {
- where = where + " and a.QQ like '%" + QQ + "%'"
- }
- if CompanyUrl != "" {
- where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
- }
- if SpecSupplier != "" {
- where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
- }
- if SpecTypeName != "" {
- where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
- }
- if Remark != "" {
- where = where + " and a.Remark like '%" + Remark + "%'"
- }
- 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 + "'"
- }
- }
- if SupplierTypeCode != "" {
- where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- //找出待办任务
- actisvc := workflow.GetActivitiService(utils.DBE)
- var certIdList string
- str := actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if str != "" {
- certIdList = str
- certIdList = certIdList + ","
- }
- str = actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if str != "" {
- certIdList = fmt.Sprintf("%s %s", certIdList, str)
- certIdList = certIdList + ","
- }
- str = actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
- if str != "" {
- certIdList = fmt.Sprintf("%s %s", certIdList, str)
- certIdList = certIdList + ","
- }
- //if actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
- // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id))
- // certIdList = certIdList + ","
- //}
- //if actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
- // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id))
- // certIdList = certIdList + ","
- //}
- //if actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
- // certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id))
- //}
- certIdList = strings.Trim(certIdList, ",")
- certIdarr := strings.Split(certIdList, ",")
- for i, item := range certIdarr {
- idx := strings.Index(item, "-")
- if idx >= 0 {
- certIdarr[i] = strings.Split(item, "-")[0]
- }
- }
- certIdList = strings.Join(certIdarr, ",")
- var list []supplier.OilSupplierView
- svc := supplier.GetOilSupplierService(utils.DBE)
- var total int64 = 0
- if (certIdList != "") {
- where += " and b.Id in (" + certIdList + ")"
- total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, 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 get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilSupplierController) GetDictList() {
- dictList := make(map[string]interface{})
- dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
- dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
- dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
- dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
- dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
- dictList["CountryList"] = areaJsonSvc.GetCountryList()
- //获取我创建的所有公司
- var list []supplier.OilSupplier
- if this.User.IsCompanyUser == 1 {
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- supplierWhere := " CreateUserId = '" + this.User.Id + "'"
- svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
- dictList["CompanyNames"] = list
- } else { //二级单位不用获取
- dictList["CompanyNames"] = list
- }
- // 部门
- orgsvc := organize.GetOrganizeService(utils.DBE)
- dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- //获得有审核权限的人员
- var users []userRole.Base_RoleList
- var auditWorkflow auditsetting.Base_OilAuditSetting
- rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
- users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
- dictList["Auditer"] = users
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取字典列表By Status
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlistbystatus/ [get]
- func (this *OilSupplierController) GetDictListByStatus() {
- //status := this.Ctx.Input.Param(":status")
- status := this.GetString("status")
- majorAduit := this.GetString("majorAduit")
- addId := this.GetString("addId")
- dictList := make(map[string]interface{})
- dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- areaJsonSvc := areajson.GetAreaJsonService(utils.DBE)
- orgsvc := organize.GetOrganizeService(utils.DBE)
- svc := supplier.GetOilSupplierService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- dictList["ManagementUnit"] = dictSvc.GetKeyValueItems("ManagementUnit")
- dictList["UnitRelation"] = dictSvc.GetKeyValueItems("UnitRelation")
- dictList["CompanyType"] = dictSvc.GetKeyValueItems("CompanyType")
- dictList["InOptions"] = dictSvc.GetKeyValueItems("InOptions")
- dictList["OperType"] = dictSvc.GetKeyValueItems("OperType")
- dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- dictList["GaodeMapChinaAreas"] = areaJsonSvc.GetGaodeMapChinaAreas()
- dictList["CountryList"] = areaJsonSvc.GetCountryList()
- //获取专业审批处室部门
- var preorglist []organize.Base_Organizetree
- //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- //topid := paramSvc.GetBaseparameterMessage("", "paramset", "HeadquartersID") // 总公司Id
- ids := orgsvc.GetAllChildUnitById("0")
- svc.GetProOrTreeList(ids, &preorglist)
- dictList["ProOrgList"] = preorglist
- var unitorglist []organize.Base_Organize
- where := "Category='Unit'and Id not in (100000004,100000003,100000002) "
- orgsvc.GetEntities(&unitorglist, where)
- dictList["UnitOrgList"] = unitorglist
- //获取我创建的所有公司
- var list []supplier.OilSupplier
- if this.User.IsCompanyUser == 1 {
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- supplierWhere := " CreateUserId = '" + this.User.Id + "'"
- svcSupplier.GetEntitysByWhere(OilSupplierName, supplierWhere, &list)
- dictList["CompanyNames"] = list
- } else { //二级单位不用获取
- dictList["CompanyNames"] = list
- }
- // 部门
- dictList["Organizes"] = orgsvc.GetCollectionDetailviewlist("'" + this.User.AccCode + "'")
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- //获得有审核权限的人员
- //var users []suppliercert.UserList
- //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- var users []userRole.Base_RoleList
- if status == suppliercert.FIRST_TRIAL_STATUS {
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
- //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
- //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
- //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
- certSrv.GetAuditUser(this.User.DepartmentId, workflow.SECOND_TRIAL, &users)
- dictList["Auditer"] = users
- } else if status == suppliercert.SECOND_TRIAL_STATUS {
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.SECOND_TRIAL, &auditWorkflow)
- } else if status == suppliercert.THIRD_TRIAL_STATUS {
- //where := "OrganizeId=" + majorAduit + " and AuditStepCode='" + workflow.SECOND_TRIAL + "'"
- //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
- certSrv.GetAuditUser(majorAduit, workflow.SECOND_TRIAL, &users)
- dictList["Auditer"] = users
- } else if status == suppliercert.PROF_AUDIT_STATUS {
- //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + workflow.PROF_AUDIT + "'"
- //rsvc.GetEntitysByWhere(OilAuditSettingName, where, &users)
- certSrv.GetAuditUser(this.User.DepartmentId, workflow.PROF_AUDIT, &users)
- dictList["Auditer"] = users
- } else if status == suppliercert.CENT_AUDIT_STATUS {
- }
- // 注册审批单位
- var registermodel register.OilCorporateInfo
- wherereg := "UserId=" + this.User.Id
- svc.GetEntity(®istermodel, wherereg)
- dictList["Register"] = registermodel
- // 所有二级单位
- var allunitorglist []organize.Base_Organize
- where = "Category='Unit'"
- orgsvc.GetEntities(&allunitorglist, where)
- dictList["Allunitorglist"] = allunitorglist
- // 管理单位
- var suppliermode supplier.OilSupplier
- orgsvc.GetEntityById(addId, &suppliermode)
- if suppliermode.MgrUnit == supplier.MGRUNIT {
- dictList["MgrUnit"] = true
- } else {
- dictList["MgrUnit"] = false
- }
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /get/:id [get]
- func (this *OilSupplierController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getandcert/:certId [get]
- func (this *OilSupplierController) GetEntityAndCert() {
- Id := this.Ctx.Input.Param(":certId")
- var model supplier.OilSupplierView
- //svc := supplier.GetOilSupplierService(utils.DBE)
- //svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
- var sql string
- sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, b.Step, b.WorkerTotal, b.ContractNum, b.UniversityNum, b.TechnicalNum, b.AboveProfNum, b.InFlag, b.ApplyTime,
- b.MiddleProfNum, b.NationalRegNum, b.NationalCertTotal, b.DesignerTotal, b.SkillerTotal, b.InStyle, b.WorkflowId, b.Status, b.ThirdAudit, b.BusinessKey, b.AuditIndex ,b.ProcessKey from ` + OilSupplierName + ` a `
- sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
- sql += ` where b.Id ='` + Id + `'`
- utils.DBE.SQL(sql).Get(&model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getbyname [get]
- func (this *OilSupplierController) GetEntityByName() {
- name := this.GetString("name")
- typecode := this.GetString("typecode")
- svc := supplier.GetOilSupplierService(utils.DBE)
- var model supplier.OilSupplierApply
- var datainfo ErrorDataInfo
- var sqlsus string
- sqlsus = `select 1 from ` + OilSupplierName + ` a `
- sqlsus += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id`
- sqlsus += ` where a.SupplierName ='` + name + `' and b.InFlag='2' and b.SupplierTypeCode='` + typecode + `'`
- var tempMap []map[string]string
- tempMap, _ = svc.DBE.QueryString(sqlsus)
- if tempMap != nil && tempMap[0]["1"] != "" {
- datainfo.Code = -1
- this.Data["json"] = &datainfo
- this.ServeJSON()
- } else {
- var sql string
- sql = `select a.*,b.InStyle,b.Status from ` + OilSupplierName + ` a `
- sql += ` left join ` + OilSupplierCertName + ` b on b.SupplierId = a.Id and b.SupplierTypeCode='` + typecode + `'`
- sql += ` where a.SupplierName ='` + name + `'`
- utils.DBE.SQL(sql).Get(&model)
- if model.SupplierName == "" {
- var model2 register.OilCorporateInfo
- svc.GetEntityByWhere(OilCorporateInfoName, "SupplierName='"+name+"' and CheckStatus='11'", &model2)
- model2.Remark = ""
- model2.Id = 0
- if model2.SupplierName == "" {
- datainfo.Code = -2
- this.Data["json"] = &datainfo
- this.ServeJSON()
- } else {
- datainfo.Code = 0
- datainfo.Item = model2
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- } else {
- datainfo.Code = 0
- datainfo.Item = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- }
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilSupplierController) AddEntity() {
- var model supplier.OilSupplier
- var modelCert suppliercert.OilSupplierCert
- var modelCertVM suppliercert.OilSupplierVM
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- json.Unmarshal(jsonBlob, &modelCertVM)
- serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- var registerUser register.OilCorporateInfo
- sql := " UserName='" + this.User.Username + "'"
- serviceCert.GetEntity(®isterUser, sql)
- canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
- var errinfo ErrorDataInfo
- if !canApply {
- errinfo.Message = "添加失败!供方用户只能申请一次"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var list []supplier.OilSupplierView
- service := supplier.GetOilSupplierService(utils.DBE)
- service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
- if len(list) > 0 {
- errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- //if model.Id <= 0 {
- // service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
- // if len(list) > 0 {
- // errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
- // errinfo.Code = -1
- // this.Data["json"] = &errinfo
- // this.ServeJSON()
- // return
- // }
- //} else {
- // service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
- // if len(list) > 0 {
- // errinfo.Message = "添加失败! 已存在相关企业的信息,或与其他企业信息重复"
- // errinfo.Code = -1
- // this.Data["json"] = &errinfo
- // this.ServeJSON()
- // return
- // }
- //}
- var session *xorm.Session
- session = utils.DBE.NewSession()
- svc := supplier.GetOilSupplierSession(session)
- svcCert := suppliercert.GetOilSupplierCertSession(session)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- defer session.Close()
- err := session.Begin()
- if model.Id <= 0 {
- _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
- } else {
- //判断基本信息是否可修改
- updateCols := svc.GetUpdateCols(OilSupplierCertName, modelCertVM.SupplierTypeCode, model.Id)
- err = svc.UpdateEntityBytbl(OilSupplierName, model.Id, &model, updateCols)
- }
- if err != nil {
- session.Rollback()
- }
- modelCert.SupplierId = model.Id
- modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
- modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
- modelCert.InStyle = modelCertVM.InStyle
- if modelCert.InStyle == suppliercert.PINGSHEN {
- modelCert.IsPay = 0
- } else {
- modelCert.IsPay = 2
- }
- modelCert.Step = 1 //企业信息保存完成
- modelCert.CreateOn = time.Now()
- modelCert.CreateBy = this.User.Realname
- modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
- if err != nil {
- session.Rollback()
- }
- // add Commit() after all actions
- err = session.Commit()
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /update/:id/:type/:instyle [post]
- func (this *OilSupplierController) UpdateEntity() {
- id := this.Ctx.Input.Param(":id")
- typeCode := this.Ctx.Input.Param(":type")
- instyle := this.Ctx.Input.Param(":instyle")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model supplier.OilSupplier
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- var list []supplier.OilSupplierView
- service := supplier.GetOilSupplierService(utils.DBE)
- service.CheckUpdateRepeatApplyInfo(OilSupplierName, OilSupplierCertName, typeCode, strconv.Itoa(model.Id), model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
- if len(list) > 0 {
- errinfo.Message = "修改失败! 已存在相关企业的信息,或与其他企业信息重复"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- //判断基本信息是否可修改
- updateCols := svc.GetUpdateCols(OilSupplierCertName, typeCode, model.Id)
- err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
- isPay := "0"
- if instyle == suppliercert.PINGSHEN {
- isPay = "0"
- } else {
- isPay = "2"
- }
- if err == nil {
- svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle + "', IsPay= " + isPay + " where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'")
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改企业人员情况实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /updatenumber/:id [post]
- func (this *OilSupplierController) UpdateNumberEntity() {
- idGroup := this.Ctx.Input.Param(":id")
- //id := strings.Split(idGroup, "_")[0]
- certId := strings.Split(idGroup, "_")[1]
- var errinfo ErrorInfo
- if certId == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var modelCert suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modelCert)
- modelCert.ModifiedOn = time.Now()
- modelCert.ModifiedBy = this.User.Realname
- modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- colcerts := []string{
- "Id",
- "InStyle",
- "WorkerTotal",
- "ContractNum ",
- "UniversityNum",
- "TechnicalNum",
- "AboveProfNum",
- "MiddleProfNum",
- "NationalRegNum",
- "NationalCertTotal",
- "DesignerTotal",
- "SkillerTotal",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- // if modelCert.Step <= 2 {
- // modelCert.Step = 2 //完成企业基本信息
- // colcerts = append(colcerts, "Step")
- // }
- err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
- if err == nil {
- errinfo.Message = "保存成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilSupplierController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model supplier.OilSupplier
- var entityempty supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /deleteall/:Id/:SupplierTypeCode [delete]
- func (this *OilSupplierController) DeleteAllEntity() {
- Id := this.Ctx.Input.Param(":Id")
- SupplierTypeCode := this.Ctx.Input.Param(":SupplierTypeCode")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- err := svc.DeleteEntityBytbl(OilSupplierCertName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
- err = svc.DeleteEntityBytbl(OilSupplierCert2FileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
- err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'")
- var model1 suppliercertsub.OilSupplierCert2File
- count1, _ := svc.GetCount(&model1, "SupplierId="+Id)
- if count1 == 0 {
- err = svc.DeleteEntityBytbl(OilSupplierFileName, "SupplierId="+Id)
- }
- var model2 suppliercert.OilSupplierCert
- count2, _ := svc.GetCount(&model2, "SupplierId="+Id)
- if count2 == 0 {
- err = svc.DeleteEntityBytbl(OilSupplierName, "Id="+Id)
- }
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 判断是否可以申请准入
- // @Description
- // @Success 200 {string} Count
- // @Failure 403 :id 为空
- // @router /iscanapply/:type [get]
- func (this *OilSupplierController) IsCanApply() {
- Type := this.Ctx.Input.Param(":type")
- var errinfo ErrorInfo
- if Type == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- var registerUser register.OilCorporateInfo
- sql := " UserName='" + this.User.Username + "'"
- svc.GetEntity(®isterUser, sql)
- canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
- if canApply {
- //判断是否是暂停
- if this.User.IsCompanyUser == 1 {
- var tempMap []map[string]string
- sql := "select 1 from OilSupplier a left join OilSupplierCert b on a.Id=b.SupplierId where (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "') and b.InFlag='2' and b.SupplierTypeCode='" + Type + "'"
- tempMap, _ = svc.DBE.QueryString(sql)
- if tempMap != nil && tempMap[0]["1"] != "" {
- errinfo.Message = "已暂停,不可申请"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "无申请记录,可以申请"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- } else {
- errinfo.Message = "无申请记录,可以申请"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- } else {
- errinfo.Message = "供方用户只能申请一次"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 判断是否可以修改供方企业信息
- // @Description
- // @Success 200 {string} Count
- // @Failure 403 :id 为空
- // @router /iscanupdatesupplier/:supplierid [get]
- func (this *OilSupplierController) CanUpdateSupplier() {
- supplierId := this.Ctx.Input.Param(":supplierid")
- var errinfo ErrorInfo
- if supplierId == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- Id, _ := strconv.Atoi(supplierId)
- svc := supplier.GetOilSupplierService(utils.DBE)
- canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id)
- if canUpdate {
- errinfo.Message = "可以修改"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "此供方已经提交准入申请,不可修改"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取二级审核人员
- // @Description 获取二级审核人员
- // @router /getauditerbydept/:deptId [get]
- func (this *OilSupplierController) GetAuditerByDept() {
- Id := this.Ctx.Input.Param(":deptId")
- auditstepcode := this.GetString("auditstepcode")
- svc := organize.GetOrganizeService(utils.DBE)
- unitId := svc.GetMyUnitDepartmentId(Id)
- //ids := svc.GetAllChildById(unitId)
- //
- //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- //var users []userRole.Base_RoleList
- //certSrv.GetAuditUser(ids, auditstepcode, &users)
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- usvc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + auditstepcode + "'"
- svc.GetEntity(&setting, where)
- ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- userIds := strings.Replace(tempstr, "uid_", "", -1)
- userIds = strings.Trim(userIds, ",")
- if userIds != "" {
- where := "Id in (" + userIds + ")" + " and UnitId=" + unitId
- svc.GetEntities(&userlist, where)
- }
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取二级初审人员
- // @Description 获取二级初审人员
- // @router /getfirauditerbydept/:deptId [get]
- func (this *OilSupplierController) GetFirAuditerByDept() {
- Id := this.Ctx.Input.Param(":deptId")
- auditstepcode := this.GetString("auditstepcode")
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- svc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + auditstepcode + "'"
- svc.GetEntity(&setting, where)
- svcdepartment := organize.GetOrganizeService(utils.DBE)
- alldep := svcdepartment.GetAllChildById(Id)
- ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- userIds := strings.Replace(tempstr, "uid_", "", -1)
- userIds = strings.Trim(userIds, ",")
- if userIds != "" {
- where := "Id in (" + userIds + ")" + "and (UnitId=" + Id + " or Departmentid in (" + alldep + ")) "
- svc.GetEntities(&userlist, where)
- }
- //svc := organize.GetOrganizeService(utils.DBE)
- //
- //ids := svc.GetAllChildById(Id)
- //
- //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- //var users []userRole.Base_RoleList
- //certSrv.GetAuditUser(ids, auditstepcode, &users)
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取二级复审人员根据初审人员
- // @Description 获取二级复审人员根据初审人员
- // @router /getauditerbyfirst/:firstId [get]
- func (this *OilSupplierController) GetAuditerByFist() {
- Id := this.Ctx.Input.Param(":firstId")
- auditstepcode := this.GetString("auditstepcode")
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- //orgSrv := organize.GetOrganizeService(utils.DBE)
- var userentity userRole.Base_User
- certSrv.GetEntityById(Id, &userentity)
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- svc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + auditstepcode + "'"
- svc.GetEntity(&setting, where)
- ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- userIds := strings.Replace(tempstr, "uid_", "", -1)
- userIds = strings.Trim(userIds, ",")
- if userIds != "" {
- where := "Id in (" + userIds + ")" + "and UnitId=" + strconv.Itoa(userentity.UnitId)
- svc.GetEntities(&userlist, where)
- }
- //svc := organize.GetOrganizeService(utils.DBE)
- //unitId := svc.GetMyUnitDepartmentId(userentity.Departmentid)
- //ids := svc.GetAllChildById(unitId)
- ////depId := strings.Split(userentity.Superior,",")
- //var users []userRole.Base_RoleList
- //certSrv.GetAuditUser(ids, auditstepcode, &users)
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取二级初审人员(不需要验证登录)
- // @Description 获取二级初审人员(不需要验证登录)
- // @router /getauditerbydeptandnologin [get]
- func (this *OilSupplierController) GetAuditerByDeptAndNoLogin() {
- Id := this.GetString("deptId")
- auditstepcode := this.GetString("auditstepcode")
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- svc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + auditstepcode + "'"
- svc.GetEntity(&setting, where)
- ids := svc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- userIds := strings.Replace(tempstr, "uid_", "", -1)
- userIds = strings.Trim(userIds, ",")
- if userIds != "" {
- where := "Id in (" + userIds + ")" + "and UnitId=" + Id
- svc.GetEntities(&userlist, where)
- }
- //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- //var users []userRole.Base_RoleList
- //certSrv.GetAuditUser(Id, auditstepcode, &users)
- // certSrv.GetAuditUserByNoLogin(Id, &users)
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title
- // @Description
- // @router /getjurisdiction [get]
- func (this *OilSupplierController) GetJurisdiction() {
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_delete")
- var datainfo ErrorDataInfo
- datainfo.Item = isauth
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /certlistinterface [get]
- func (this *OilSupplierController) GetEntityListInterface() {
- //获取分页信息
- //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
- // }
- //}
- status := this.GetString("status")
- if status == "1" {
- where += "b.InStyle='1'"
- } else if status == "2" {
- where += "b.InStyle='4'"
- } else if status == "3" {
- where += "b.InStyle='5'"
- } else if status == "4" {
- where += "b.InStyle=''"
- } else if status == "5" {
- where += "b.InStyle=''"
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var interfaceData []supplier.InterfaceData
- err := svc.GetInterfaceData(OilSupplierName, OilSupplierFileName, &interfaceData, where)
- var errinfo ErrorDataInfo
- if err == nil {
- errinfo.Message = "成功!"
- errinfo.Code = 0
- errinfo.Item = &interfaceData
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getentitybycommercialno/:commercialNo [get]
- func (this *OilSupplierController) GetEntityByCommercialNo() {
- commercialNo := this.Ctx.Input.Param(":commercialNo")
- where := "CommercialNo = '" + commercialNo + "'"
- var model supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByWhere(OilSupplierName, where, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 更新文件上传
- // @Description 更新文件上传
- // @Param id path string true
- // @Success 200 {object}
- // @router /editsubfile/:id [put]
- func (this *OilSupplierController) EditSubfile() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model supplierscenefile.OilSupplierSceneFile
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
- model.FileUrl = strings.Trim(model.FileUrl, "$")
- model.FileName = strings.Trim(model.FileName, "$")
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- where := "SupplierId=" + id
- svc.DeleteEntityBytbl(OilSupplierSceneFileName, where)
- _, err := svc.InsertEntity(&model)
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title get 导入excel
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /importexcel [get]
- func (this *OilSupplierController) ImportExcel() {
- url := this.GetString("ExcelUrl")
- var errorinfo ErrorInfo
- if url == "" {
- errorinfo.Code = -2
- errorinfo.Message = "导入失败!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- log.Printf("url:==" + url) // http://60.30.245.229//upfile/dc1/2,063156edd288
- extranetIP := utils.Cfg.MustValue("server", "extranetIP")
- localIP := utils.Cfg.MustValue("server", "localIP")
- if strings.Index(url, extranetIP) >= 0 {
- url = strings.Replace(url, extranetIP, localIP, 1)
- }
- _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
- filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
- utils.DownloadFile(url, filename, _dir)
- t := time.Now()
- filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
- xlFile, err := xlsx.OpenFile(filePath)
- //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
- if err != nil {
- fmt.Printf("open failed: %s\n", err)
- }
- var sheet = xlFile.Sheets[0]
- var errLineNum string
- for i := 1; i < len(sheet.Rows); i++ {
- lineNo := strconv.Itoa(i + 1)
- if len(sheet.Rows[i].Cells) != 0 {
- this.OperationCell(svc, lineNo, sheet.Rows[i].Cells, &errLineNum)
- }
- }
- os.Remove(filePath)
- if errLineNum != "" {
- errorinfo.Code = -1
- errorinfo.Message = "导入失败!错误行号:" + errLineNum
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- } else {
- elapsed := time.Since(t)
- log.Println(elapsed)
- errorinfo.Code = 0
- errorinfo.Message = "导入成功!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- }
- func (this *OilSupplierController) OperationCell(svc *supplier.OilSupplierService, lineNo string, cellsArr []*xlsx.Cell, errLineNum *string) {
- defer func() {
- if err := recover(); err != nil {
- log.Println("err"+lineNo, err)
- *errLineNum += lineNo + ","
- }
- }()
- cells := cellsArr
- supplierName := strings.TrimSpace(cells[0].Value)
- oilCertificateNo := ""
- if len(cells) >= 2 {
- oilCertificateNo = strings.TrimSpace(cells[1].Value)
- }
- cols := []string{"PACNumber"}
- var entity supplier.OilSupplier
- entity.PACNumber = oilCertificateNo
- where := "SupplierName='" + supplierName + "'"
- err := svc.UpdateEntityBywheretbl(OilSupplierName, &entity, cols, where)
- if err != nil {
- panic(err)
- }
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /getscenefilelist [get]
- func (this *OilSupplierController) GetSceneFileList() {
- supplierId := this.GetString("SupplierId")
- var model supplierscenefile.OilSupplierSceneFile
- svc := supplierscenefile.GetSupplierScenefileService(utils.DBE)
- where := "SupplierId=" + supplierId
- svc.GetEntity(&model, where)
- var errinfo ErrorDataInfo
- errinfo.Item = model
- errinfo.Code = 1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
|