| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/audithistory"
- "dashoo.cn/backend/api/business/auditsetting"
- "dashoo.cn/backend/api/business/oilsupplier/infochange"
- "dashoo.cn/backend/api/business/oilsupplier/qualchange"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
- "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
- "dashoo.cn/backend/api/business/paymentinfo"
- "dashoo.cn/backend/api/business/register"
- "dashoo.cn/business2/parameter"
- "dashoo.cn/business2/permission"
- "dashoo.cn/business2/userRole"
- "encoding/json"
- "fmt"
- "log"
- "reflect"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
- "dashoo.cn/backend/api/business/workflow"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type InfoChangeController struct {
- BaseController
- }
- type InfoShenHeModel struct {
- FirstAudit int
- SecondAudit int
- InfoId int
- SuccessStatus int
- AuditorRemark string
- SuppId int
- }
- type InfoChangeItemsAll struct {
- InfochangeForm []infoitems
- SupplierId string
- MInfoId string
- }
- type infoitems struct {
- SelectItem string
- SelectItemName string
- BeChangeInfo string
- ChangeInfo string
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /get/:id [get]
- func (this *InfoChangeController) GetEntity() {
- CertId := this.Ctx.Input.Param(":id")
- var model []infochange.OilInfoChangeItem
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := " SupplierId = " + CertId
- svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
- var datainfo DataInfo
- datainfo.Items = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /getmain/:id [get]
- func (this *InfoChangeController) GetMainEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model []infochange.OilInfoChange
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := " Id = " + Id
- svc.GetEntitysByWhere(OilInfoChangeName, where, &model)
- var datainfo DataInfo
- datainfo.Items = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /getAccessCardNo/:id [get]
- func (this *InfoChangeController) GetAccessCardNo() {
- SuppId := this.Ctx.Input.Param(":id")
- var model []suppliercert.OilSupplierCert
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := " SupplierId = " + SuppId
- svc.GetEntitysByOrderbyWhere(OilSupplierCertName, where, "SupplierTypeCode asc", &model)
- var datainfo DataInfo
- datainfo.Items = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /auditget/:id [get]
- func (this *InfoChangeController) GetEntityThen() {
- InfoId := this.Ctx.Input.Param(":id")
- var model []infochange.OilInfoChangeItem
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := " InfoId = " + InfoId
- svc.GetEntitysByWhere(OilInfoChangeItemName, where, &model)
- var datainfo DataInfo
- datainfo.Items = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /supplist [get]
- func (this *InfoChangeController) GetSuppList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " b.Id is not null "
- orderby := "b.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")
- 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")
- 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 + "'"
- }
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- 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 + "')"
- } else {
- //超级管理员和有查看所有数据权限的用户不加条件
- svcPerm := permission.GetPermissionService(utils.DBE)
- isauth := svcPerm.IsAuthorized(this.User.Id, "oil_system.infochange.AllRecord")
- if !svcPerm.IsAdmin(this.User.Id) && !isauth {
- where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
- }
- }
- var list []infochange.SuppModelInfo
- total := svc.GetSuppPagingEntitiesWithOrderBytbl(OilSupplierName, OilInfoChangeName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- //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} []infochange.OilInfoChange
- // @router /alllist [get]
- func (this *InfoChangeController) GetAllEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1"
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- SupplierId := this.GetString("SupplierId")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierName := this.GetString("SupplierName")
- //if SupplierId != "" {
- // var model supplier.OilSupplier
- // sv := supplier.GetOilSupplierService(utils.DBE)
- // sv.GetEntityByIdBytbl(OilSupplierName, SupplierId, &model)
- // SupplierName = model.SupplierName
- //}
- CreateOn := this.GetString("CreateOn")
- if SupplierName != "" {
- where = where + " and Name like '%" + SupplierName + "%'"
- }
- if SupplierId != "" {
- where = where + " and SupplierId = '" + SupplierId + "'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- var list []infochange.OilUsedName
- //total := svc.GetUsedNameWithOrderBytbl(OilSupplierName, OilInfoChangeItemName, page.CurrentPage, page.Size, orderby, asc, &list, where)
- total := svc.GetOldNameWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []infochange.OilInfoChange
- // @router /list [get]
- func (this *InfoChangeController) 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
- }
- }
- SupplierTypeName := this.GetString("SupplierTypeName")
- RecUnitId := this.GetString("RecUnitId")
- AccessCardNo := this.GetString("AccessCardNo")
- SupplierName := this.GetString("SupplierName")
- CreateOn := this.GetString("CreateOn")
- if SupplierTypeName != "" {
- where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- if RecUnitId != "" {
- where = where + " and RecUnitId like '%" + RecUnitId + "%'"
- }
- if AccessCardNo != "" {
- where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- //找出待办任务
- actisvc := workflow.GetActivitiService(utils.DBE)
- certIdList := actisvc.GetMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
- appendIdarr := strings.Split(certIdList, ",")
- for i, item := range appendIdarr {
- idx := strings.Index(item, "-")
- if idx >= 0 {
- appendIdarr[i] = strings.Split(item, "-")[0]
- }
- }
- certIdList = strings.Join(appendIdarr, ",")
- svc := infochange.GetInfoChangeService(utils.DBE)
- var list []infochange.OilInfoChange
- var total int64 = 0
- if certIdList != "" {
- where += " and Id in (" + certIdList + ")"
- 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 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /getinfoforitem [get]
- func (this *InfoChangeController) GetInfoForItem() {
- certId := this.GetString("certId")
- selctitem := this.GetString("selctitem")
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := "Id =" + utils.ToStr(certId)
- var selecteditem = svc.GetInfoforItem(""+OilSupplierName, selctitem, where)
- this.Data["json"] = &selecteditem
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getchangelist/:id [get]
- func (this *InfoChangeController) GetChangeEntity() {
- Id := this.Ctx.Input.Param(":id")
- InfoId := this.GetString("InfomainId")
- var models [2]supplier.OilSupplier
- var model supplier.OilSupplier
- var enumModel supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
- models[0] = model
- var infoitems []infochange.OilInfoChangeItem
- where := " SupplierId = " + Id + " and InfoId =" + InfoId
- where = where + " and ChangeStatus = 0"
- svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoitems)
- tmpModel := &model
- enumModel = *tmpModel
- immumodel := reflect.ValueOf(&enumModel)
- elem := immumodel.Elem()
- if len(infoitems) == 0 {
- models[1] = enumModel
- this.Data["json"] = &models
- this.ServeJSON()
- return
- } else {
- for _, info := range infoitems {
- fmt.Println(info.SelectItem)
- fmt.Println(";;;;;;;;;", elem.FieldByName(info.SelectItem).Type().String())
- if elem.FieldByName(info.SelectItem).Type().String() == "int64" {
- intchangeinfo, _ := strconv.ParseInt(info.ChangeInfo, 10, 64)
- elem.FieldByName(info.SelectItem).SetInt(intchangeinfo)
- } else if elem.FieldByName(info.SelectItem).Type().String() == "float64" {
- floatchangeinfo, _ := strconv.ParseFloat(info.ChangeInfo, 64)
- elem.FieldByName(info.SelectItem).SetFloat(floatchangeinfo)
- } else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
- t, _ := time.Parse("2006-01-02", info.ChangeInfo[0:10])
- elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
- } else {
- elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
- }
- }
- models[1] = enumModel
- this.Data["json"] = &models
- this.ServeJSON()
- }
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []annualaudit.OilAnnualAudit
- // @router /mytasks [get]
- func (this *InfoChangeController) GetMyTaskEntityList() {
- //获取分页信息
- 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
- }
- }
- SupplierTypeName := this.GetString("SupplierTypeName")
- RecUnitId := this.GetString("RecUnitId")
- AccessCardNo := this.GetString("AccessCardNo")
- SupplierName := this.GetString("SupplierName")
- CreateOn := this.GetString("CreateOn")
- if SupplierTypeName != "" {
- where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- if RecUnitId != "" {
- where = where + " and RecUnitId like '%" + RecUnitId + "%'"
- }
- if AccessCardNo != "" {
- where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
- var list []annualaudit.OilAnnualAudit
- //找出待办任务
- actisvc := workflow.GetActivitiService(utils.DBE)
- certIdList := actisvc.GetMyTasks(workflow.OIL_AUDIT_APPLY, this.User.Id)
- where += " and Id in (" + certIdList + ")"
- where += " and Status != -2 "
- //根据部门查询待办任务
- total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
- //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
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *InfoChangeController) 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 infochange.OilInfoChangeItem
- var entityempty infochange.OilInfoChangeItem
- svc := infochange.GetInfoChangeService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(""+OilInfoChangeItemName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "信息变更")
- 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 /delinfochangech/:Id [delete]
- func (this *InfoChangeController) DelInfoChangech() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- var infoChange infochange.OilInfoChange
- where := "Id=" + Id + " and Status <= '0'"
- has1 := svc.GetEntity(&infoChange, where)
- if !has1 {
- errinfo.Message = "删除失败"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- where = "ParentId=" + Id
- svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
- where = "InfoId=" + Id
- svc.DeleteEntityBytbl(OilInfoChangeItemName, where)
- where = "Id=" + Id
- err := svc.DeleteEntityBytbl(OilInfoChangeName, where)
- where = "SupplierId=" + strconv.Itoa(infoChange.SupplierId) + " and FileName=''"
- err = svc.DeleteEntityBytbl(OilSupplierFileName, where)
- 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 /delfile/:Id [delete]
- func (this *InfoChangeController) DelFile() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- var file supplierfile.OilSupplierFile
- where := "Id=" + Id
- has1 := svc.GetEntity(&file, where)
- if !has1 {
- errinfo.Message = "删除失败"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- // 之前的资质改状态, 新增资质删除
- var err error
- if file.FileUrl != "" {
- cols := []string{"IsDelete"}
- file.IsDelete = 1
- _, err = svc.UpdateEntityByIdCols(Id, &file, cols)
- } else {
- where := "FileId=" + Id
- err = svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
- err = svc.DeleteEntityById(Id, &file)
- }
- 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 /deletenewfile/:Id [delete]
- func (this *InfoChangeController) DeleteNewFile() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := "FileId=" + Id
- err := svc.DeleteEntityBytbl(OilQualChangeDetailName, where)
- 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 /recall [post]
- func (this *InfoChangeController) Recall() {
- SupplierId := this.GetString("SupplierId")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- var errinfo ErrorInfo
- svc := infochange.GetInfoChangeService(utils.DBE)
- var file supplierfile.OilSupplierFile
- where := "SupplierId=" + SupplierId + " and SupplierTypeCode in ('000', '" + SupplierTypeCode + "')" + " and IsDelete=1"
- cols := []string{"IsDelete"}
- file.IsDelete = 0
- err := svc.UpdateEntityBywheretbl(OilSupplierFileName, &file, cols, where)
- 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} controllers.Request
- // @router /addinfochangeitem [post]
- func (this *InfoChangeController) AddInfoChangeItem() {
- var model infochange.OilInfoChangeItem
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := infochange.GetInfoChangeService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err := svc.InsertEntityBytbl(""+OilInfoChangeItemName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model.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 /addinfochangeitemch [post]
- func (this *InfoChangeController) AddInfoChangeItemCh() {
- var model InfoChangeItemsAll
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := infochange.GetInfoChangeService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- var err error
- where := " SupplierId = " + model.SupplierId
- where = where + " and InfoId = " + model.MInfoId
- var deleteEntity infochange.OilInfoChangeItem
- delMainId, _ := strconv.Atoi(model.MInfoId)
- deleteEntity.InfoId = delMainId
- svc.DBE.Delete(deleteEntity)
- var infoitementitys []infochange.OilInfoChangeItem
- for i := 0; i < len(model.InfochangeForm); i++ {
- var infoitementity infochange.OilInfoChangeItem
- infoitementity.SelectItem = model.InfochangeForm[i].SelectItem
- infoitementity.SelectItemName = model.InfochangeForm[i].SelectItemName
- infoitementity.ChangeInfo = model.InfochangeForm[i].ChangeInfo
- infoitementity.BeChangeInfo = model.InfochangeForm[i].BeChangeInfo
- infoitementity.ChangeStatus = 0
- infoitementity.SupplierId, _ = strconv.Atoi(model.SupplierId)
- infoitementity.InfoId, _ = strconv.Atoi(model.MInfoId)
- infoitementity.CreateOn = time.Now()
- infoitementity.CreateBy = this.User.Realname
- infoitementity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- infoitementitys = append(infoitementitys, infoitementity)
- }
- _, err = svc.InsertEntityBytbl(""+OilInfoChangeItemName, &infoitementitys)
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- //errinfo.Item = model.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 获取二级初审人员
- // @router /getauditerbydept/:deptId [get]
- func (this *InfoChangeController) GetAuditerByDept() {
- Id := this.Ctx.Input.Param(":deptId")
- //var auditWorkflow auditsetting.Base_OilAuditSetting
- rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, Id, workflow.FIRST_TRIAL, &auditWorkflow)
- var userlist []userRole.Base_User
- where := " CompanyId = " + Id
- rsvc.GetEntities(&userlist, where)
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取企业法规处人员
- // @Description 获取企业法规处人员
- // @router /getauditer [get]
- func (this *InfoChangeController) GetAuditer() {
- //svc := infochange.GetInfoChangeService(utils.DBE)
- //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- svc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
- svc.GetEntity(&setting, where)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
- 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=" + topid
- svc.GetEntities(&userlist, where)
- }
- //var users []userRole.Base_RoleList
- //certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
- //var users []suppliercert.UserList
- // where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
- //svc.GetEntitysByWhere(OilAuditSettingName, where, &users)
- var datainfo ErrorDataInfo
- datainfo.Item = userlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增信息变更
- // @Success 200 {object} controllers.Request
- // @router /addinfomain [post]
- func (this *InfoChangeController) AddInfoMain() {
- SupplierId := this.GetString("SupplierId")
- Remark := this.GetString("Remark")
- var infochmain infochange.OilInfoChange
- var infochm []infochange.OilInfoChange
- var suppliermodel supplier.OilSupplier
- var errinfo ErrorDataInfo
- svc := infochange.GetInfoChangeService(utils.DBE)
- where := " SupplierId = " + SupplierId + " and Status < 11 and Status != 8"
- svc.GetEntitysByWhere(OilInfoChangeName, where, &infochm)
- if len(infochm) > 0 {
- errinfo.Message = "有已提交在申请中的信息变更,请审批完成后再提交!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc.GetEntityById(SupplierId, &suppliermodel)
- infochmain.Status = "0"
- infochmain.SupplierName = suppliermodel.SupplierName
- infochmain.OldSupplierName = suppliermodel.SupplierName
- infochmain.PACNumber = suppliermodel.PACNumber
- infochmain.SupplierCertificate = suppliermodel.SupplierCertificate
- infochmain.MgrUnit = suppliermodel.MgrUnit
- infochmain.OilCertificateNo = suppliermodel.OilCertificateNo
- infochmain.OperType = suppliermodel.OperType
- infochmain.Country = suppliermodel.Country
- infochmain.MaunAgent = suppliermodel.MaunAgent
- infochmain.CommercialNo = suppliermodel.CommercialNo
- infochmain.OrganCode = suppliermodel.OrganCode
- infochmain.SupplierId, _ = strconv.Atoi(SupplierId)
- infochmain.Remark = Remark
- infochmain.CreateOn = time.Now()
- infochmain.CreateBy = this.User.Realname
- infochmain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err := svc.InsertEntityBytbl(OilInfoChangeName, &infochmain)
- if err == nil {
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = infochmain.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取信息变更企业名称
- // @Description 获取实体
- // @Success 200 {object}
- // @router /addsupplierlist [get]
- func (this *InfoChangeController) GetAddSupplierList() {
- svc := infochange.GetInfoChangeService(utils.DBE)
- var supplierlist []annualaudit.Suppliername
- where := "1=1"
- //企业用户必须加创建人条件
- if this.User.IsCompanyUser == 1 {
- where = where + " and CreateUserId = '" + this.User.Id + "'"
- }
- //else { // 二级单位可以为所有企业提交信息变更 2020-03-12
- // //超级管理员和有查看所有数据权限的用户不加条件
- // 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 a.CreateUserId = '" + this.User.Id + "'"
- // }
- //}
- //supplierlist = svc.GetSupplierList(""+OilSupplierName, where)
- svc.GetEntitysByWhere(OilSupplierName, where, &supplierlist)
- var datainfo DataInfo
- datainfo.Items = supplierlist
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 提交审批
- // @Description 提交审批
- // @Success 200 {object} controllers.Request
- // @router /commitaudit/:id [post]
- func (this *InfoChangeController) CommitAuditEntity() {
- //suppId := this.Ctx.Input.Param(":id")
- firstAudit := this.GetString("auditer")
- fushenauditer := this.GetString("fushenauditer")
- Remark := this.GetString("Remark")
- InfoId := this.GetString("MInfoId")
- var setting auditsetting.Base_OilAuditSetting
- var userlist []userRole.Base_User
- usvc := userRole.GetUserService(utils.DBE)
- where := ""
- if this.User.IsCompanyUser == 1 {
- where = "AuditStepCode='" + workflow.SUB_OFFICE_BG + "'"
- usvc.GetEntity(&setting, where)
- ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- uids := strings.Replace(tempstr, "uid_", "", -1)
- uids = strings.Trim(uids, ",")
- if uids != "" {
- where := "Id in (" + uids + ")" + " and UnitId=" + firstAudit
- usvc.GetEntities(&userlist, where)
- }
- userIds := ""
- for _, tmpUser := range userlist {
- userIds += strconv.Itoa(tmpUser.Id) + ","
- }
- firstAudit = strings.Trim(userIds, ",")
- }
- //取出审批列表
- svc := infochange.GetInfoChangeService(utils.DBE)
- var infochangeentity infochange.OilInfoChange
- infwhere := " Id = " + InfoId
- svc.GetEntity(&infochangeentity, infwhere)
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- processInstanceId := ""
- businessKey := ""
- businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
- result := strconv.Itoa(this.User.IsCompanyUser)
- processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, result, infochangeentity.SupplierTypeCode, infochangeentity.SupplierName)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = businessKey
- ActiComplete.UserNames = firstAudit
- ActiComplete.UserId = this.User.Id
- ActiComplete.Result = result
- ActiComplete.Remarks = Remark
- ActiComplete.CallbackUrl = ""
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
- if this.User.IsCompanyUser == 1 {
- infochangeentity.Status = suppliercert.FEN_TRIAL_STATUS
- } else {
- infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS
- }
- infochangeentity.WorkFlowId = processInstanceId
- infochangeentity.FenbanAudit, _ = strconv.Atoi(firstAudit)
- infochangeentity.FirstAudit, _ = strconv.Atoi(firstAudit)
- infochangeentity.SecondAudit, _ = strconv.Atoi(fushenauditer)
- infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
- infochangeentity.BusinessKey = ActiComplete.BusinessKey
- infochangeentity.CreateOn = time.Now()
- infochangeentity.CreateBy = this.User.Realname
- infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "WorkflowId",
- "Status",
- "Step",
- "FenbanAudit",
- "FirstAudit",
- "SecondAudit",
- "AuditIndex",
- "BusinessKey",
- "CreateOn",
- "CreateBy",
- "CreateUserId",
- }
- svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
- }
- // @Title 提交审批
- // @Description 提交审批
- // @Success 200 {object} controllers.Request
- // @router /audit/:id [post]
- func (this *InfoChangeController) AuditEntity() {
- suppId := this.Ctx.Input.Param(":id")
- firstAudit := this.GetString("auditer")
- Remark := this.GetString("Remark")
- InfoId := this.GetString("MInfoId")
- //取出审批列表
- svc := infochange.GetInfoChangeService(utils.DBE)
- var infoitems []infochange.OilInfoChangeItem
- where := " SupplierId = " + suppId
- svc.GetEntities(&infoitems, where)
- var infochangeentity infochange.OilInfoChange
- infwhere := " Id = " + InfoId
- svc.GetEntity(&infochangeentity, infwhere)
- var infomodel infochange.OilInfoChangeItem
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- var items string
- for i := 0; i < len(infoitems); i++ {
- items = fmt.Sprintf("%s %s %s %s", items, infoitems[i].SelectItem, ","+infoitems[i].BeChangeInfo, ","+infoitems[i].ChangeInfo+";")
- }
- items = strings.Trim(items, ";")
- infowhere := " Id = " + InfoId
- svc.Updateentityinfo(OilInfoChangeName, items, infowhere)
- //修改从表infoid
- for i := 0; i < len(infoitems); i++ {
- infomodel.InfoId, _ = strconv.Atoi(InfoId)
- err := svc.UpdateEntityBytbl(OilInfoChangeItemName, infoitems[i].Id, &infomodel, []string{"InfoId"})
- fmt.Println(err)
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- processInstanceId := ""
- businessKey := ""
- if infochangeentity.WorkFlowId == "0" || len(infochangeentity.WorkFlowId) <= 0 {
- //启动工作流
- businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
- processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id)
- }
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = businessKey
- ActiComplete.UserNames = firstAudit
- ActiComplete.UserId = this.User.Id
- ActiComplete.Result = "1"
- ActiComplete.Remarks = Remark
- ActiComplete.CallbackUrl = ""
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
- infochangeentity.WorkFlowId = processInstanceId
- infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
- infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
- infochangeentity.BusinessKey = ActiComplete.BusinessKey
- infochangeentity.CreateOn = time.Now()
- infochangeentity.CreateBy = this.User.Realname
- infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "WorkflowId",
- "Status",
- "Step",
- "FirstAudit",
- "AuditIndex",
- "BusinessKey",
- "CreateOn",
- "CreateBy",
- "CreateUserId",
- }
- svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
- }
- // @Title 审批
- // @Description 审批
- // @Success 200 {object} controllers.Request
- // @router /infoaudit [post]
- func (this *InfoChangeController) InfoAudit() {
- t := time.Now()
- svc := infochange.GetInfoChangeService(utils.DBE)
- var jsonblob = this.Ctx.Input.RequestBody
- var dataother InfoShenHeModel
- json.Unmarshal(jsonblob, &dataother)
- //取出审批列表
- var infoid = dataother.InfoId
- var infomodel infochange.OilInfoChange
- svc.GetEntityById(utils.ToStr(dataother.InfoId), &infomodel)
- var infoitems []infochange.OilInfoChangeItem
- where := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and InfoId = " + utils.ToStr(dataother.InfoId)
- svc.GetEntities(&infoitems, where)
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //审核状态判断进行的操作
- step := 2
- status := ""
- backstatus := "0"
- var userIds string
- if infomodel.Status == suppliercert.FEN_TRIAL_STATUS {
- userIds = utils.ToStr(dataother.FirstAudit)
- status = suppliercert.FIRST_TRIAL_STATUS
- step = 2
- backstatus = suppliercert.NO_FEN_TRIAL_STATUS
- if dataother.SuccessStatus == 1 {
- infomodel.FirstAudit = dataother.FirstAudit
- infomodel.SecondAudit = dataother.SecondAudit
- cols := []string{
- "FirstAudit",
- "SecondAudit",
- }
- svc.UpdateEntityByIdCols(infoid, infomodel, cols)
- }
- }
- if infomodel.Status == suppliercert.FIRST_TRIAL_STATUS {
- userIds = utils.ToStr(infomodel.SecondAudit)
- status = suppliercert.SECOND_TRIAL_STATUS
- step = 2
- backstatus = suppliercert.NOPASS_STATUS
- } else if infomodel.Status == suppliercert.SECOND_TRIAL_STATUS {
- status = suppliercert.CENT_AUDIT_STATUS
- backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
- step = 2
- //dictSvc := items.GetItemsService(utils.DBE)
- //deptIds := dictSvc.GetKeyValueItems("CENT_AUDIT")
- //var users []userRole.Base_RoleList
- //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- //for _, dept := range deptIds {
- // certSrv.GetAuditUser(dept.Value, workflow.PROF_REGULATION, &users)
- // for _, tmpUser := range users {
- // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
- // }
- //}
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT")
- var userlist []userRole.Base_User
- var setting auditsetting.Base_OilAuditSetting
- usvc := userRole.GetUserService(utils.DBE)
- where := "AuditStepCode='" + workflow.PROF_REGULATION + "'"
- svc.GetEntity(&setting, where)
- ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId))
- tempstr := strings.Join(ids, ",")
- uids := strings.Replace(tempstr, "uid_", "", -1)
- uids = strings.Trim(uids, ",")
- if uids != "" {
- where := "Id in (" + uids + ")" + " and UnitId=" + topid
- svc.GetEntities(&userlist, where)
- }
- for _, tmpUser := range userlist {
- userIds += strconv.Itoa(tmpUser.Id) + ","
- }
- userIds = strings.Trim(userIds, ",")
- } else if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
- status = suppliercert.ALL_PASE_STATUS
- step = 3
- backstatus = suppliercert.NO_CENT_AUDIT_STATUS
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = infomodel.BusinessKey
- ActiComplete.UserNames = userIds
- ActiComplete.UserId = this.User.Id
- ActiComplete.Remarks = dataother.AuditorRemark
- ActiComplete.CallbackUrl = ""
- var myerr error
- if dataother.SuccessStatus == 1 {
- ActiComplete.Result = "1"
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
- //信息更新
- var infochangeitemmodel infochange.OilInfoChangeItem
- var supmodel supplier.OilSupplier
- infochangeitemmodel.ChangeStatus = 1
- infomodel.Status = status
- itemswhere := "InfoId = " + utils.ToStr(infoid)
- myerr = svc.UpdateEntityBywheretbl(OilInfoChangeItemName, &infochangeitemmodel, []string{"ChangeStatus"}, itemswhere)
- myerr = this.updatesupplier(OilSupplierName, dataother.SuppId, infoitems, supmodel)
- //资质更新
- //where := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and SupType = 2"
- //var supfilemodel supplierfile.OilSupplierFile
- //supfilemodel.SupType = 3
- //svc.UpdateEntityBywheretbl(OilSupplierFileName, &supfilemodel, []string{"SupType"}, where)
- // 级别 一级变二级 删除不符合的准入项和资质
- for _, item := range infoitems {
- if item.SelectItem == "Grade" && (item.BeChangeInfo == "1" && item.ChangeInfo == "2") {
- this.BusinessDelete(utils.ToStr(dataother.SuppId))
- }
- }
- // 删除资质及准入项
- this.FileDelete(strconv.Itoa(dataother.SuppId))
- s := time.Since(t)
- log.Println(s, "============================")
- var qualdetail []qualchange.OilQualChangeDetail
- where1 := "SupplierId = " + utils.ToStr(dataother.SuppId) + " and ParentId=" + strconv.Itoa(infoid)
- svc.GetEntities(&qualdetail, where1)
- if len(qualdetail) > 0 {
- for i := 0; i < len(qualdetail); i++ {
- var supfilemodel supplierfile.OilSupplierFile
- supfilemodel.FileName = qualdetail[i].FileName
- supfilemodel.FileUrl = qualdetail[i].FileUrl
- supfilemodel.EffectDate = qualdetail[i].EffectDate
- svc.UpdateEntityBytbl(OilSupplierFileName, qualdetail[i].FileId, &supfilemodel, []string{"FileName", "FileUrl", "EffectDate"})
- }
- }
- }
- infomodel.Status = status
- infomodel.Step = step
- if receiveVal == "true" {
- cols := []string{
- "Id",
- "Status",
- "Step",
- }
- _, myerr = svc.UpdateEntityByIdCols(infoid, infomodel, cols)
- if myerr == nil {
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "提交失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- } else {
- ActiComplete.Result = "0"
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- if infomodel.Status == suppliercert.CENT_AUDIT_STATUS {
- infomodel.Status = backstatus
- } else {
- infomodel.Status = backstatus
- // 审批历史
- var audithistoryentity audithistory.Base_AuditHistory
- audithistoryentity.EntityId = infoid
- audithistoryentity.WorkflowId = infomodel.WorkFlowId
- audithistoryentity.Process = ActiComplete.ProcessKey
- audithistoryentity.BusinessKey = ActiComplete.BusinessKey
- audithistoryentity.Type = "04"
- audithistoryentity.BackStep = infomodel.Status
- audithistoryentity.Index = infomodel.AuditIndex
- audithistoryentity.CreateOn = time.Now()
- audithistoryentity.CreateBy = this.User.Realname
- audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, myerr = svc.InsertEntity(audithistoryentity)
- infomodel.WorkFlowId = ""
- }
- infomodel.Step = 1
- cols := []string{
- "Status",
- "Step",
- "WorkFlowId",
- }
- _, myerr := svc.UpdateEntityByIdCols(infoid, infomodel, cols)
- if myerr == nil {
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "提交失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- }
- }
- // @Title 企业用户提交按钮 --启动工作流
- // @Description 企业用户提交按钮
- // @Success 200 {object} controllers.Request
- // @router /company-audit/:id [post]
- func (this *InfoChangeController) CompanyAuditEntity() {
- infoId := this.Ctx.Input.Param(":id")
- unitId := this.GetString("unitId")
- AuditRemark := this.GetString("AuditRemark")
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- if this.User.IsCompanyUser == 0 {
- // 0二级单位; 1企业用户
- panic("非企业用户,请用分办功能提交!")
- }
- //取出准入申请表
- infoSrv := infochange.GetInfoChangeService(utils.DBE)
- var infoChangeEntity infochange.OilInfoChange
- infoSrv.GetEntityById(infoId, &infoChangeEntity)
- // TODO 检查是否可以提交
- //infoSrv.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.Id), certId)
- //取出企业主表
- supplierSvc := supplier.GetOilSupplierService(utils.DBE)
- var supplierEntity supplier.OilSupplier
- //检查是否可提交
- supplierSvc.GetEntityById(infoChangeEntity.SupplierId, &supplierEntity)
- status, _ := strconv.Atoi(infoChangeEntity.Status)
- if status > 0 {
- panic("工作流已经启动,请刷新重试!")
- }
- stepCode := workflow.SUB_OFFICE_BG
- auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
- approverIds := auditSettingService.GetApproverIdsByStepCodeAndUnitId(stepCode, unitId)
- if approverIds == "" {
- panic("该分办单位未配置审批人")
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- //启动工作流
- businessKey := infoChangeEntity.BusinessKey
- processInstanceId := infoChangeEntity.WorkFlowId
- // 如果被驳回,不再新启工作流
- if processInstanceId == "" {
- businessKey = infoId + "-" + strconv.Itoa(infoChangeEntity.AuditIndex)
- processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, "1", infoChangeEntity.SupplierTypeCode, supplierEntity.SupplierName)
- if len(processInstanceId) <= 0 {
- panic("工作流启动失败!")
- }
- infoChangeEntity.AuditIndex += 1
- }
- // 将启动和工作流,选择的分办单位id记录下来
- cols := []string{
- "Id",
- "WorkflowId",
- "BusinessKey",
- "ProcessKey",
- "CommitComId",
- "AuditIndex",
- }
- infoChangeEntity.ProcessKey = workflow.OIL_INFO_CHANGE
- infoChangeEntity.BusinessKey = businessKey
- infoChangeEntity.WorkFlowId = processInstanceId
- infoChangeEntity.CommitComId = unitId
- infoSrv.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = businessKey
- ActiComplete.UserId = this.User.Id
- ActiComplete.Result = "1" //提交给二级单位分办
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- }
- // @Title 二级单位提交审批 --启动工作流
- // @Description 二级单位提交审批
- // @Success 200 {object} controllers.Request
- // @router /unit-audit/:id [post]
- func (this *InfoChangeController) UnitAuditEntity() {
- infoId := this.Ctx.Input.Param(":id")
- firstAudit := this.GetString("FirstAudit")
- secondAudit := this.GetString("SecondAudit")
- AuditRemark := this.GetString("AuditRemark")
- userId := this.User.Id
- var baseUserInfo userRole.Base_User
- userService := userRole.GetUserService(utils.DBE)
- userService.GetEntityById(userId, &baseUserInfo)
- unitId := baseUserInfo.UnitId
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //取出准入表信息
- svc := infochange.GetInfoChangeService(utils.DBE)
- var infoChangeEntity infochange.OilInfoChange
- svc.GetEntityById(infoId, &infoChangeEntity)
- // TODO 检查是否可提交
- //svc.IsSupplierCertCanSubmit(strconv.Itoa(supplierCertEntity.Id), certId)
- //取出企业主表
- supplierSvc := supplier.GetOilSupplierService(utils.DBE)
- var supplierEntity supplier.OilSupplier
- supplierSvc.GetEntityById(infoChangeEntity.SupplierId, &supplierEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- //启动工作流
- businessKey := infoChangeEntity.BusinessKey
- processInstanceId := infoChangeEntity.WorkFlowId
- // 如果被驳回,不再新启工作流
- if processInstanceId == "" {
- businessKey = infoId + "-" + strconv.Itoa(infoChangeEntity.AuditIndex)
- processInstanceId = svcActiviti.StartProcess2(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id, "1", infoChangeEntity.SupplierTypeCode, supplierEntity.SupplierName)
- if len(processInstanceId) <= 0 {
- panic("工作流启动失败!")
- }
- infoChangeEntity.AuditIndex += 1
- }
- // 将启动和工作流,选择的初审和复审人员保存下来
- cols := []string{
- "Id",
- "FirstAudit",
- "SecondAudit",
- "WorkflowId",
- "BusinessKey",
- "ProcessKey",
- "CommitComId",
- "AuditIndex",
- }
- infoChangeEntity.ProcessKey = workflow.OIL_INFO_CHANGE
- infoChangeEntity.BusinessKey = businessKey
- infoChangeEntity.WorkFlowId = processInstanceId
- infoChangeEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
- infoChangeEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
- infoChangeEntity.CommitComId = strconv.Itoa(unitId)
- svc.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
- ActiComplete.UserId = this.User.Id // 当前审批操作人员
- //ActiComplete.UserNames = secondAudit // 当前审批操作人员
- ActiComplete.Result = "2" //分办提交给二级单位初审
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- }
- // @Title 二级单位分办 --审批
- // @Description 二级分办
- // @Success 200 {object} controllers.Request
- // @router /separate-audit/:id [post]
- func (this *InfoChangeController) SeparateAuditEntity() {
- infoId := this.Ctx.Input.Param(":id")
- //SuppId := this.GetString("SuppId")
- Result := this.GetString("Result")
- firstAudit := this.GetString("FirstAudit")
- secondAudit := this.GetString("SecondAudit")
- AuditRemark := this.GetString("AuditRemark")
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- // 取出准入表信息
- infoSrv := infochange.GetInfoChangeService(utils.DBE)
- var infoChangeEntity infochange.OilInfoChange
- infoSrv.GetEntityById(infoId, &infoChangeEntity)
- if Result == "1" {
- // 将选择的初审和复审人员保存下来
- cols := []string{
- "FirstAudit",
- "SecondAudit",
- }
- infoChangeEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
- infoChangeEntity.SecondAudit, _ = strconv.Atoi(secondAudit)
- infoSrv.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
- ActiComplete.UserId = this.User.Id // 审批人员
- // ActiComplete.UserNames = secondAudit // 初审人员
- ActiComplete.Result = Result //分办完成后只向前走
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- }
- // @Title 分办之后的各级审批 --审批 包含:二级单位初审、复审, 企管法规处评审
- // @Description 分办之后的各级审批
- // @Success 200 {object} controllers.Request
- // @router /common-audit/:id [post]
- func (this *InfoChangeController) CommonAuditEntity() {
- infoId := this.Ctx.Input.Param(":id")
- result := this.GetString("result")
- AuditRemark := this.GetString("AuditRemark")
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //取出变更表信息
- infoSrv := infochange.GetInfoChangeService(utils.DBE)
- var infoChangeEntity infochange.OilInfoChange
- infoSrv.GetEntityById(infoId, &infoChangeEntity)
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
- ActiComplete.BusinessKey = infoChangeEntity.BusinessKey
- ActiComplete.UserId = this.User.Id //审批人员
- ActiComplete.Result = result //前台审批[同意、不同意]
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal != "true" {
- panic("工作流异常,请联系管理员!" + receiveVal)
- }
- var infoChangeEntityAfterUpdate infochange.OilInfoChange
- infoSrv.GetEntityById(infoId, &infoChangeEntityAfterUpdate)
- if infoChangeEntityAfterUpdate.Status == suppliercert.STORE_STATUS {
- fmt.Println("资质变更入库完成, 开始实际变更信息: supplierId" + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId) + "变更信息表ID: " + infoId)
- var oilSupplier supplier.OilSupplier
- var oldName supplier.OilSupplierOldName
- var info infochange.OilInfoChangeItem
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByWhere(OilInfoChangeItemName, "SelectItem = 'SupplierName' and InfoId = " + infoId, &info)
- // 曾用名存到主表
- oilSupplier.OldSupplierName = info.BeChangeInfo
- svc.UpdateEntityBywheretbl(OilSupplierName, &oilSupplier, []string{"OldSupplierName"}, "Id = " + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId))
- oldName.OldName = info.BeChangeInfo
- oldName.Name = info.ChangeInfo
- oldName.SupplierId = infoChangeEntityAfterUpdate.SupplierId
- oldName.GfId = 0
- oldName.CreateOn = info.CreateOn
- oldName.CreateBy = info.CreateBy
- oldName.CreateUserId = info.CreateUserId
- // 曾用名存到子表
- svc.InsertEntityBytbl("OilSupplierOldName", &oldName)
- this.updateChangeInfo(infoChangeEntityAfterUpdate.SupplierId, infoId)
- }
- }
- // @Title 交费用户确认交费
- // @Description 交费用户确认交费
- // @Success 200 {object} controllers.Request
- // @router /update-pay-status/:id [post]
- func (this *InfoChangeController) UpdatePayStatus() {
- infoId := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if infoId == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- infoSrv := infochange.GetInfoChangeService(utils.DBE)
- var infoChangeEntity infochange.OilInfoChange
- infoSrv.GetEntityById(infoId, &infoChangeEntity)
- paySrv := paymentinfo.GetPaymentService(utils.DBE)
- var paymentInfoEntities []paymentinfo.OilPaymentInfo
- err := paySrv.GetPaymentInfoBySrcId(infoId, "1", &paymentInfoEntities)
- if err != nil {
- errinfo.Message = "未知错误,请稍后再试!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- if len(paymentInfoEntities) == 1 {
- for _, item := range paymentInfoEntities {
- if item.IsPay == "1" {
- errinfo.Message = "已确认交费!请耐心等待"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- if item.IsPay == "2" {
- errinfo.Message = "已交费!请勿重复操作!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- }
- sql := "UPDATE OilPaymentInfo SET IsPay ='1' where SrcId=" + infoId + " and PayType='1'"
- paySrv.DBE.Exec(sql)
- errinfo.Message = "确认交费成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- //更新供方信息表
- func (this *InfoChangeController) updatesupplier(supname string, suppid int, infoitems []infochange.OilInfoChangeItem, supmodel supplier.OilSupplier) error {
- svc := infochange.GetInfoChangeService(utils.DBE)
- var err error
- if len(infoitems) > 0 {
- for i := 0; i < len(infoitems); i++ {
- //var cols []string
- //cols = append(cols, infoitems[i].SelectItem)
- where := " Id = " + utils.ToStr(suppid)
- var sql string
- if infoitems[i].SelectItem == "SetupTime" {
- sql = `UPDATE ` + supname + ` set ` + infoitems[i].SelectItem + ` = '` + infoitems[i].ChangeInfo[0:10] + `' where ` + where
- } else {
- sql = `UPDATE ` + supname + ` set ` + infoitems[i].SelectItem + ` = '` + infoitems[i].ChangeInfo + `' where ` + where
- }
- _, err = svc.DBE.Exec(sql)
- //err = svc.UpdateEntityBytbl(OilSupplierName, suppid, &supmodel, cols)
- }
- }
- return err
- }
- func (this *InfoChangeController) BusinessDelete(SupplierId string) {
- //SupplierTypeCode := "01"
- //var IsManufacturer string
- //根据Id查出OilSupplierCertSub的SubClassId
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
- //filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- //var DelCertSublList []suppliercertsub.OilSupplierCertSub
- // 级别 一级变二级 把物资类一级的删掉
- whereDel := "SupplierId=" + SupplierId + " and SupplierTypeCode='01' and GoodsLevel='1'"
- //svc.GetEntities(&DelCertSublList, whereDel)
- svc.DeleteEntityBytbl(OilSupplierCertSubName, whereDel)
- //Id := ""
- //for _, item := range DelCertSublList {
- // Id = Id + "," + strconv.Itoa(item.Id)
- //}
- //Id = strings.Trim(Id, ",")
- //if Id != "" {
- // Ids := strings.Split(Id, ",")
- //
- // //
- // var CertSublList []suppliercertsub.OilSupplierCertSub
- // where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode // 没有删除的准入范围
- // svc.GetEntities(&CertSublList, where)
- // SubClassIds := ""
- // for _, CertSub := range CertSublList {
- //
- // SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
- // }
- // var SurplusList []supplierfile.FileList
- // SubClassIds = strings.Trim(SubClassIds, ",")
- // if SubClassIds != "" {
- // if SupplierTypeCode == "01" {
- // //SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds, IsManufacturer)
- // } else if SupplierTypeCode == "02" {
- // SurplusList = filesvc.GetBasicNeedFileList(SubClassIds)
- // } else if SupplierTypeCode == "03" {
- // SurplusList = filesvc.GetTechNeedFileList(SubClassIds)
- // }
- // }
- // fileNames := ""
- // for _, CertSub := range SurplusList {
- // fileNames += CertSub.FileName + ","
- // }
- //
- // for i := 0; i < len(Ids); i++ {
- // IsManufacturer = filesvc.CheckIsManuf(Ids[i])
- // if SubClassIds != "" {
- // if SupplierTypeCode == "01" {
- // var CertSublList2 []suppliercertsub.OilSupplierCertSub
- // wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
- // svc.GetEntities(&CertSublList2, wheregood)
- // SubClassIds2 := ""
- // for _, CertSub := range CertSublList2 {
- // SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
- // }
- // SubClassIds2 = strings.Trim(SubClassIds2, ",")
- // SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
- // }
- // }
- // if fileNames == "" {
- // for _, CertSub := range SurplusList {
- // fileNames += CertSub.FileName + ","
- // }
- // }
- // var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
- // var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
- //
- // where := " Id= " + Ids[i]
- // svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
- //
- // //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
- //
- // supplierId := datamain.SupplierId
- // where = "SupplierId=" + strconv.Itoa(supplierId)
- // svc.GetEntities(&datamain2, where)
- // flag := 0
- // if len(datamain2) == 1 {
- // flag = 1
- // }
- // subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
- // //根据SubClassId查出此准入范围所拥有的资质名称
- // var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
- // if datamain.SupplierTypeCode == "01" {
- // needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
- // } else if datamain.SupplierTypeCode == "02" {
- // needList = filesvc.GetBasicNeedFileList(strconv.Itoa(subClassId))
- // } else {
- // needList = filesvc.GetTechNeedFileList(strconv.Itoa(subClassId))
- // }
- //
- // var mustField string
- // mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
- //
- // //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
- // for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
- //
- // if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
- // continue
- // }
- // if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
- // continue
- // }
- // if datamain.SupplierTypeCode == "01" {
- // where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- // } else {
- // where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- // }
- // svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
- //
- // }
- //
- // // TODO: 删除准入范围和资质对应关系表
- // /*where = " SupplierId=" + strconv.Itoa(datamain.SupplierId) + " and SupplierTypeCode =" + SupplierTypeCode + " and SubClassId=" + strconv.Itoa(subClassId)
- // svc.DeleteEntityBytbl(OilSupplierCert2FileName, where)*/
- //
- // where = " Id= " + Ids[i] + " and SupplierTypeCode =" + SupplierTypeCode
- // svc.DeleteEntityBytbl(OilSupplierCertSubName, where) //删除OilSupplierCertSub单条准入范围
- //
- // }
- //}
- }
- func (this *InfoChangeController) FileDelete(supplierId string) {
- s := time.Now()
- where := "SupplierId=" + supplierId + " and IsDelete=1"
- svc := infochange.GetInfoChangeService(utils.DBE)
- var delfiles []supplierfile.OilSupplierFile
- svc.GetEntities(&delfiles, where)
- delfilenames := ""
- for _, delfile := range delfiles {
- delfilenames += delfile.NeedFileType + ","
- }
- fmt.Println("del==" + delfilenames)
- var sub []suppliercertsub.OilSupplierCertSub
- weresup := "SupplierId=" + supplierId
- svc.GetEntitysByWhere(OilSupplierCertSubName, weresup, &sub)
- for _, item := range sub {
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetGoodsNeedFileList(strconv.Itoa(item.SubClassId))
- for _, needfile := range needList {
- if strings.Index(delfilenames, needfile.FileName) > -1 {
- where := "Id=" + strconv.Itoa(item.Id)
- svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
- break
- }
- }
- }
- svc.DeleteEntityBytbl(OilSupplierFileName, where)
- sp := time.Since(s)
- log.Println(sp, "++++++++++++++++++++")
- }
- func (this *InfoChangeController) updateChangeInfo(supplierId int, infoId string) {
- var infoItems []infochange.OilInfoChangeItem
- where := " SupplierId = " + strconv.Itoa(supplierId) + " and InfoId =" + infoId
- where = where + " and ChangeStatus = 0"
- var supModel supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoItems)
- //修改主表信息
- this.updatesupplier(OilSupplierName, supplierId, infoItems, supModel)
- // 级别 一级变二级 删除不符合的准入项
- for _, item := range infoItems {
- if item.SelectItem == "Grade" {
- if item.BeChangeInfo == "1" && item.ChangeInfo == "2" {
- this.BusinessDelete(utils.ToStr(supplierId))
- }
- }
- }
- this.FileDelete(strconv.Itoa(supplierId))
- t := time.Now()
- s := time.Since(t)
- log.Println(s, "============================")
- var qualDetail []qualchange.OilQualChangeDetail
- where1 := "SupplierId = " + utils.ToStr(supplierId) + " and ParentId=" + infoId
- svc1 := infochange.GetInfoChangeService(utils.DBE)
- svc1.GetEntities(&qualDetail, where1)
- //更新 变更的资质
- if len(qualDetail) > 0 {
- for i := 0; i < len(qualDetail); i++ {
- var supFileModel supplierfile.OilSupplierFile
- supFileModel.FileName = qualDetail[i].FileName
- supFileModel.FileUrl = qualDetail[i].FileUrl
- supFileModel.EffectDate = qualDetail[i].EffectDate
- svc.UpdateEntityBytbl(OilSupplierFileName, qualDetail[i].FileId, &supFileModel, []string{"FileName", "FileUrl", "EffectDate"})
- }
- }
- }
|