| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713 |
- 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/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 and b.OldSupplierName is not null"
- orderby := "a.Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = "a." + Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierName := this.GetString("SupplierName")
- CreateOn := this.GetString("CreateOn")
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- 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 + "'"
- }
- }
- svc := infochange.GetInfoChangeService(utils.DBE)
- var list []infochange.OilUsedName
- total := svc.GetUsedNameWithOrderBytbl(OilSupplierName, OilInfoChangeName, 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"
- 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 a.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
- }
- }
- }
- //更新供方信息表
- 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)
- 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条资质数据
- }
- 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, "++++++++++++++++++++")
- }
|