| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369 |
- 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/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "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"
- "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)
- 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} 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 < 4"
- 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 {
- //超级管理员和有查看所有数据权限的用户不加条件
- 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)
- 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() {
- 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_THIRD_TRIAL_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)
- //var qualdetail []qualchange.OilQualChangeDetail
- //svc.UpdateEntityBytbl(OilSupplierFileName, qualdetail[i].FileId, &supfilemodel, []string{"SupType"})
- //where := "SupplierId = " + utils.ToStr(dataother.SuppId)
- //svc.GetEntities(&qualdetail, where)
- //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
- // supfilemodel.SupType = 3
- // svc.UpdateEntityBytbl(OilSupplierFileName, qualdetail[i].FileId, &supfilemodel, []string{"FileName", "FileUrl", "EffectDate","SupType"})
- // }
- //}
- }
- 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
- 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
- }
|