| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude"
- "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/business2/parameter"
- "encoding/json"
- "fmt"
- "log"
- "reflect"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type OilSupplierCertAppendSubController struct {
- BaseController
- }
- type AppendChangeItemsAll struct {
- InfochangeForm []appenditems
- SupplierId string
- MInfoId string
- }
- type appenditems struct {
- SelectItem string
- SelectItemName string
- BeChangeInfo string
- ChangeInfo string
- }
- // @Title 获取列表
- // @Description 获取列表
- // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
- // @router /getList [get]
- func (this *OilSupplierCertAppendSubController) GetList() {
- //获取分页信息
- 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
- // }
- //}
- //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
- //if SupplierCertAppendId != "" {
- // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
- //}
- SupplierCertId := this.GetString("SupCertId")
- SupplierTypeCode := this.GetString("SupTypeCode")
- suwhere := " SupplierCertId = " + SupplierCertId + " and SupplierTypeCode = " + SupplierTypeCode
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub
- //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
- //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
- total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, suwhere)
- var dataInfo DataInfo
- dataInfo.CurrentItemCount = total
- dataInfo.PageIndex = page.CurrentPage
- dataInfo.ItemsPerPage = page.Size
- dataInfo.Items = list
- this.Data["json"] = &dataInfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description 获取列表
- // @Success 200 {object} []suppliercertappendsub.OilSupplierCertAppendSub
- // @router /getListInandApp [get]
- func (this *OilSupplierCertAppendSubController) GetListInAndApp() {
- //获取分页信息
- 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
- // }
- //}
- //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
- //if SupplierCertAppendId != "" {
- // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
- //}
- SupplierCertId := this.GetString("SupCertId")
- SupplierTypeCode := this.GetString("SupTypeCode")
- SupplierCertAppendId := this.GetString("SupplierCertAppendId")
- searchCode := this.GetString("searchCode")
- where := `((SupplierCertId = ` + SupplierCertId + ` AND SupplierTypeCode = '` + SupplierTypeCode + `' AND TYPE IN ('1', '3'))
- OR (SupplierCertId = ` + SupplierCertId + ` AND SupplierTypeCode = '` + SupplierTypeCode + `' AND SupplierCertAppendId = ` + SupplierCertAppendId + `)) `
- //" SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode
- if searchCode != "" {
- where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
- }
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub
- //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
- //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
- total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
- var dataInfo DataInfo
- if list == nil {
- dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
- } else {
- 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} []suppliercertappendsub.OilSupplierCertAppendSub
- // @router /getMyList [get]
- func (this *OilSupplierCertAppendSubController) GetMyList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- SupplierCertId := this.GetString("SupCertId")
- SupplierTypeCode := this.GetString("SupTypeCode")
- SuppAppendId := this.GetString("SupplierCertAppendId")
- searchCode := this.GetString("searchCode")
- where := " SupplierCertId = " + SupplierCertId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and SupplierCertAppendId = " + SuppAppendId
- if searchCode != "" {
- where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
- }
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub
- //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
- total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
- var dataInfo DataInfo
- if list == nil {
- dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
- } else {
- 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} []suppliercertappendsub.OilSupplierCertAppendSub
- // @router /getListappend [get]
- func (this *OilSupplierCertAppendSubController) GetListAppend() {
- //获取分页信息
- 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
- // }
- //}
- //SupplierCertAppendId := this.GetString("SupplierCertAppendId")
- //if SupplierCertAppendId != "" {
- // where = where + " and SupplierCertAppendId = " + SupplierCertAppendId
- //}
- SupplierCertAppendId := this.GetString("SupplierCertAppendId")
- SupplierCertId := this.GetString("SupCertId")
- SupplierTypeCode := this.GetString("SupTypeCode")
- searchCode := this.GetString("searchCode")
- where := " SupplierCertId = " + SupplierCertId + " and SupplierCertAppendId= " + SupplierCertAppendId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and Type in(2,3) "
- if searchCode != "" {
- where += " and (Code like '" + strings.Trim(searchCode, " ") + "%' or Name like '%" + strings.Trim(searchCode, " ") + "%')"
- }
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub
- //svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
- //svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
- total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
- var dataInfo DataInfo
- if list == nil {
- dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
- } else {
- 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} controllers.Request
- // @router /addappendsub [post]
- func (this *OilSupplierCertAppendSubController) AddAppendSub() {
- var model suppliercertsub.OilSupplierCertSub
- var err error
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- model.CertSubStatus = "-1"
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var submodel suppliercertsub.OilSupplierCertSub
- where_certsub := " SupplierCertId = " + utils.ToStr(model.SupplierCertId) + " and SupplierTypeCode = 02"
- where_certsub += " and SubClassId = '" + utils.ToStr(model.SubClassId) + "'"
- has := svc.GetEntityByWhere(OilSupplierCertSubName, where_certsub, &submodel)
- if !has {
- //添加到准入分类表中
- _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
- // TODO: 删除准入范围和资质对应关系表
- /*var supplierCertModel suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- svcCert.GetEntityById(model.SupplierCertId, &supplierCertModel)
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(model.SupplierId, &supplierModel)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- var needList []supplierfile.FileList
- if model.SupplierTypeCode == "01" {
- // needList = filesvc.GetGoodsNeedFileList(model.SubClassId)
- } else if model.SupplierTypeCode == "02" {
- needList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.SubClassId))
- } else {
- // needList = filesvc.GetTechNeedFileList(model.SubClassId)
- }
- if supplierCertModel.InStyle == "4" {
- var needFile supplierfile.FileList
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- if err == nil {
- var list []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in (02,000) and SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
- // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
- for i := 0; i < len(needList); i++ {
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = model.SupplierId
- //加入对应表OilSupplierCert2File
- var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
- cert2File.SupplierId = model.SupplierId
- cert2File.SupplierCertId = model.SupplierCertId
- cert2File.SupplierCertSubId = model.Id
- cert2File.SupplierTypeCode = model.SupplierTypeCode
- cert2File.SubClassId = model.SubClassId
- cert2File.Code = model.Code
- cert2File.Name = model.Name
- cert2File.NeedFileType = needList[i].FileName
- svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
- }
- }*/
- }
- 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} business.device.DeviceChannels
- // @router /addtechbus [post]
- func (this *OilSupplierCertAppendSubController) AddTechBus() {
- var jsonblob = this.Ctx.Input.RequestBody
- var datamain suppliercertsub.OilSupplierCertSub
- var dataother suppliercertsub.TechnologySubModel
- json.Unmarshal(jsonblob, &datamain)
- json.Unmarshal(jsonblob, &dataother)
- var supplierCertModel suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
- for n := 0; n < len(dataother.CheckList); n++ {
- where_sub := "SupplierTypeCode = 03 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
- where_sub += " and SubClassId = '" + strconv.Itoa(dataother.CheckList[n].Id) + "'"
- var model suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
- if !has {
- // TODO: 不存在的准入范围直接就新增了,因为前台已经调用了checkLost检查过是否缺少资质,有时间可以在些方法补充验证
- datamain.SubClassId = dataother.CheckList[n].Id
- datamain.Code = dataother.CheckList[n].Code
- datamain.Name = dataother.CheckList[n].Name
- datamain.Remark = dataother.Remark
- datamain.CertSubStatus = "-1"
- datamain.IsDelete = 0
- datamain.CreateBy = this.User.Realname
- datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- datamain.Id = 0
- svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
- // TODO: 删除准入范围和资质对应关系表
- /*paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetTechNeedFileList(strconv.Itoa(dataother.CheckList[n].Id))
- if supplierCertModel.InStyle == "4" {
- var needFile supplierfile.FileList
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- var list []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in (03,000) and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
- // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
- for i := 0; i < len(needList); i++ {
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = dataother.SupplierId
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- //加入对应表OilSupplierCert2File
- var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
- cert2File.SupplierId = dataother.SupplierId
- cert2File.SupplierCertId = dataother.SupplierCertId
- cert2File.SupplierCertSubId = datamain.Id
- cert2File.SupplierTypeCode = dataother.SupplierTypeCode
- cert2File.SubClassId= dataother.CheckList[n].Id
- cert2File.Code = dataother.CheckList[n].Code
- cert2File.Name = dataother.CheckList[n].Name
- cert2File.NeedFileType = needList[i].FileName
- svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
- }*/
- }
- }
- var errinfo ErrorDataInfo
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 批量添加增项准入范围--物资类
- // @Description 批量添加增项准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /addgoodsbus [post]
- func (this *OilSupplierCertAppendSubController) AddGoodsBus() {
- var jsonblob = this.Ctx.Input.RequestBody
- var datamain suppliercertsub.OilSupplierCertSub
- var dataother suppliercertsub.SupplierCertSubModel
- json.Unmarshal(jsonblob, &datamain)
- json.Unmarshal(jsonblob, &dataother)
- var supplierCertModel suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- svcCert.GetEntityById(datamain.SupplierCertId, &supplierCertModel)
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
- var goods goodsaptitude.GoodsBusiness1
- svcGoods := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
- for n := 0; n < len(dataother.CheckList); n++ {
- svcGoods.GetEntityJoin2(OilGoodsAptitudeName, OilGoodsAptitudeClassName, &goods, "Code = '"+dataother.CheckList[n].Code+"'")
- where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
- where_sub += " and SubClassId = '" + strconv.Itoa(goods.Id) + "'"
- var model suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
- if !has {
- // TODO: 不存在的准入范围直接就新增了,因为前台已经调用了checkLost检查过是否缺少资质,有时间可以在些方法补充验证
- datamain.SubClassId = goods.Id
- datamain.Code = dataother.CheckList[n].Code
- datamain.Name = dataother.CheckList[n].Name
- datamain.GoodsLevel = goods.GoodsLevel
- datamain.CertSubStatus = "-1"
- datamain.Remark = dataother.Remark
- datamain.IsDelete = 0
- datamain.CreateBy = this.User.Realname
- datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- datamain.Id = 0
- log.Print("增项【可】添加不存在的准入范围,SupplierId: " + strconv.Itoa(datamain.SupplierId) + "AppendId: " + strconv.Itoa(datamain.SupplierCertAppendId) + "Code: " + datamain.Code)
- svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
- log.Println("添加成功")
- // TODO: 删除准入范围和资质对应关系表
- /*paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id,"2")
- if supplierCertModel.InStyle == "4" {
- var needFile supplierfile.FileList
- //战略合作协议扫描件
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- var list []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
- // mustField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
- for i := 0; i < len(needList); i++ {
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = dataother.SupplierId
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- //加入对应表OilSupplierCert2File
- var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
- cert2File.SupplierId = dataother.SupplierId
- cert2File.SupplierCertId = dataother.SupplierCertId
- cert2File.SupplierCertSubId = datamain.Id
- cert2File.SupplierTypeCode = dataother.SupplierTypeCode
- cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
- cert2File.IsManuf = "2"
- cert2File.Code = dataother.CheckList[n].Code
- cert2File.Name = dataother.CheckList[n].Name
- cert2File.NeedFileType = needList[i].FileName
- svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
- }*/
- } else {
- log.Print("增项【不可】再次添加已添加过的准入范围,SupplierId: " + strconv.Itoa(datamain.SupplierId) + "AppendId: " + strconv.Itoa(datamain.SupplierCertAppendId) + "Code: " + datamain.Code)
- }
- }
- var errinfo ErrorDataInfo
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilSupplierCertAppendSubController) UpdateEntity() {
- var errinfo ErrorInfo
- var model suppliercertappendsub.OilSupplierCertAppendSub
- id := this.Ctx.Input.Param(":id")
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "SortFlag",
- "Code",
- "Name",
- "Remark",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilSupplierCertAppendSubName, id, &model, cols)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除
- // @Description 删除信息
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilSupplierCertAppendSubController) 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 suppliercertappendsub.OilSupplierCertAppendSub
- var entityempty suppliercertappendsub.OilSupplierCertAppendSub
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertAppendSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "增项分类")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改是否为供应商
- // @Description
- // @router /updatemanufacturerappend/:Id/:SupplierId/:IsManufacturer [get]
- func (this *OilSupplierCertAppendSubController) UpdateManufacturerAppend() {
- Id := this.Ctx.Input.Param(":Id")
- IsManufacturer := this.Ctx.Input.Param(":IsManufacturer")
- SupplierId := this.Ctx.Input.Param(":SupplierId")
- SupplierTypeCode := "01"
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var CertSublList []suppliercertsub.OilSupplierCertSub
- where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode ='" + SupplierTypeCode + "'" // 没有删除的准入范围
- svc.GetEntities(&CertSublList, where)
- var SupplierCertId int
- for _, CertSub := range CertSublList {
- SupplierCertId = CertSub.SupplierCertId
- }
- var supplierCertModel suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- svcCert.GetEntityById(SupplierCertId, &supplierCertModel)
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(SupplierId, &supplierModel)
- var error error
- if IsManufacturer == "2" {
- var errinfo ErrorInfo
- //根据Id查出OilSupplierCertSub的SubClassId
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- SubClassIds := ""
- for _, CertSub := range CertSublList {
- SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
- }
- var SurplusList []supplierfile.FileList
- SubClassIds = strings.Trim(SubClassIds, ",")
- 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)
- }
- }
- fileNames := ""
- for _, CertSub := range SurplusList {
- fileNames += CertSub.FileName + ","
- }
- var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
- var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
- where = " Id= " + Id
- 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 //定义存储所拥有资质名称的数组
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
- 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
- }
- where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
- 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()
- }
- }
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "1")
- //if supplierCertModel.InStyle == "4" {
- // var needFile supplierfile.FileList
- // //战略合作协议扫描件
- // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- // needList = append(needList, needFile)
- //}
- var list []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in (01,000) and IsManuf in ('0','1') and SupplierId =" + strconv.Itoa(supplierId)
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
- mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
- for i := 0; i < len(needList); i++ {
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = supplierId
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- //加入对应表OilSupplierCertFile
- if strings.Contains(mustField, needList[i].FileName+",") {
- entity.SupplierTypeCode = "000"
- entity.IsManuf = "0"
- } else {
- entity.SupplierTypeCode = "01"
- entity.IsManuf = "1"
- }
- entity.NeedFileType = needList[i].FileName
- entity.FileType = 1
- //entity.EffectDate = time.Now()
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- entity.SupType = 2
- entity.SupplierCertSubId = datamain.SupplierCertAppendId
- isRepeat := false
- for j := 0; j < len(list); j++ {
- if list[j].NeedFileType == needList[i].FileName {
- isRepeat = true
- break
- }
- }
- if isRepeat == true {
- continue
- }
- svc.InsertEntityBytbl(OilSupplierFileName, &entity)
- }
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer =1 where Id=" + Id + "")
- } else if IsManufacturer == "1" {
- var errinfo ErrorInfo
- //根据Id查出OilSupplierCertSub的SubClassId
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- SubClassIds := ""
- for _, CertSub := range CertSublList {
- SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
- }
- var SurplusList []supplierfile.FileList
- SubClassIds = strings.Trim(SubClassIds, ",")
- 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)
- }
- }
- fileNames := ""
- for _, CertSub := range SurplusList {
- fileNames += CertSub.FileName + ","
- }
- var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
- var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
- where = " Id= " + Id
- 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 //定义存储所拥有资质名称的数组
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
- 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
- }
- where := " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- err := svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
- 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()
- }
- }
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "2")
- //if supplierCertModel.InStyle == "4" {
- // var needFile supplierfile.FileList
- // //战略合作协议扫描件
- // needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- // needList = append(needList, needFile)
- //}
- var list []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId =" + strconv.Itoa(supplierId)
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- //"营业执照,组织代码,组织机构代码证,税务登记证,税务登记,开户许可,银行开户许可证,承诺书,诚信合规承诺书,企业信息系统截图,战略合作协议扫描件,"
- mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName")
- for i := 0; i < len(needList); i++ {
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = supplierId
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- //加入对应表OilSupplierCertFile
- if strings.Contains(mustField, needList[i].FileName+",") {
- entity.SupplierTypeCode = "000"
- entity.IsManuf = "0"
- } else {
- entity.SupplierTypeCode = "01"
- entity.IsManuf = "2"
- }
- entity.NeedFileType = needList[i].FileName
- entity.FileType = 1
- //entity.EffectDate = time.Now()
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- entity.SupType = 2
- entity.SupplierCertSubId = datamain.SupplierCertAppendId
- isRepeat := false
- for j := 0; j < len(list); j++ {
- if list[j].NeedFileType == needList[i].FileName {
- isRepeat = true
- break
- }
- }
- if isRepeat == true {
- continue
- }
- svc.InsertEntityBytbl(OilSupplierFileName, &entity)
- }
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set IsManufacturer=2 where Id=" + Id + "")
- }
- var errinfo ErrorDataInfo
- if error == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getchangelist/:id [get]
- func (this *OilSupplierCertAppendSubController) 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 []suppliercertappendsub.OilAppendChangeItem
- where := " SupplierId = " + Id + " and InfoId =" + InfoId
- where = where + " and ChangeStatus = 0"
- svc.GetEntitysByWhere(OilAppendChangeItemName, 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 获取实体
- // @Success 200 {object} annualaudit.OilAnnualAudit
- // @router /auditget/:id [get]
- func (this *OilSupplierCertAppendSubController) GetEntityThen() {
- InfoId := this.Ctx.Input.Param(":id")
- var model []suppliercertappendsub.OilAppendChangeItem
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- where := " InfoId = " + InfoId
- svc.GetEntitysByWhere(OilAppendChangeItemName, where, &model)
- var datainfo DataInfo
- datainfo.Items = model
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /addinfochangeitemch [post]
- func (this *OilSupplierCertAppendSubController) AddInfoChangeItemCh() {
- var model AppendChangeItemsAll
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- var err error
- where := " SupplierId = " + model.SupplierId
- where = where + " and InfoId = " + model.MInfoId
- var deleteEntity suppliercertappendsub.OilAppendChangeItem
- delMainId, _ := strconv.Atoi(model.MInfoId)
- deleteEntity.InfoId = delMainId
- svc.DBE.Delete(deleteEntity)
- var infoitementitys []suppliercertappendsub.OilAppendChangeItem
- for i := 0; i < len(model.InfochangeForm); i++ {
- var infoitementity suppliercertappendsub.OilAppendChangeItem
- 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(""+OilAppendChangeItemName, &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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /filelist [get]
- func (this *OilSupplierCertAppendSubController) FileList() {
- page := this.GetPageInfoForm()
- var list []suppliercertappendsub.OilAppendChangeDetail1
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- where := " 1=1"
- orderby := "a.SupplierTypeCode"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierId := this.GetString("SupplierId")
- MInfoId := this.GetString("MInfoId")
- if SupplierId != "" {
- where = where + " and a.SupplierId = '" + SupplierId + "'"
- }
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if SupplierTypeCode != "" {
- where = where + " and a.SupplierTypeCode in ( '000', '" + SupplierTypeCode + "')"
- }
- total := svc.GetQualPagingEntities(OilSupplierFileName, OilAppendChangeDetailName, page.CurrentPage, page.Size, orderby, asc, &list, where, MInfoId)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 资质文件变更上传
- // @Description 更新文件上传
- // @Param id path string true
- // @Success 200 {object}
- // @router /editqualchange/:id [put]
- func (this *OilSupplierCertAppendSubController) EditQualChange() {
- 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 suppliercertappendsub.OilAppendChangeDetail
- var jsonblob = this.Ctx.Input.RequestBody
- svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- json.Unmarshal(jsonblob, &model)
- model.FileUrl = strings.Trim(model.FileUrl, "$")
- model.FileName = strings.Trim(model.FileName, "$")
- model.OldFileUrl = strings.Trim(model.OldFileUrl, "$")
- model.OldFileName = strings.Trim(model.OldFileName, "$")
- var supplierfile supplierfile.OilSupplierFile
- svc.GetEntityByIdBytbl(OilSupplierFileName, model.Id, &supplierfile)
- if supplierfile.FileUrl == "" {
- //区别 更新前和更新后文件
- supplierfile.FileUrl = strings.Trim(model.FileUrl, "$")
- supplierfile.FileName = strings.Trim(model.FileName, "$")
- supplierfile.EffectDate = model.EffectDate
- }
- supplierfile.ModifiedOn = time.Now()
- supplierfile.ModifiedUserId, _ = strconv.Atoi(this.User.Id)
- supplierfile.ModifiedBy = this.User.Realname
- supplierfile.OtherRemark = model.Remark
- svc.UpdateEntityBywheretbl(OilSupplierFileName, &supplierfile, []string{"EffectDate", "FileUrl", "FileName", "ModifiedOn", "ModifiedUserId", "ModifiedBy", "OtherRemark"}, "Id = " + strconv.Itoa(model.Id))
- var err error
- var entity suppliercertappendsub.OilAppendChangeDetail
- var qualdetaimodel []suppliercertappendsub.OilAppendChangeDetail
- qdwhere := " SupplierId = " + utils.ToStr(model.SupplierId) + " and FileId = " + utils.ToStr(model.Id) + " and ParentId=" + id
- svc.GetEntitysByWhere(OilAppendChangeDetailName, qdwhere, &qualdetaimodel)
- entity = model
- entity.Id = 0
- entity.ParentId, _ = strconv.Atoi(id)
- entity.SupplierCertId = model.SupplierCertId
- entity.FileId = model.Id
- if len(qualdetaimodel) == 0 {
- entity.CreateOn = time.Now()
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err = svc.InsertEntityBytbl(OilAppendChangeDetailName, &entity)
- } else {
- err = svc.UpdateEntityBywheretbl(OilAppendChangeDetailName, &entity, []string{"EffectDate", "FileUrl", "FileName", "OtherRemark"}, qdwhere)
- }
- 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 *OilSupplierCertAppendSubController) 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 := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
- where := "FileId=" + Id
- err := svc.DeleteEntityBytbl(OilAppendChangeDetailName, 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()
- }
- }
|