| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/goodsaptitudeclass"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub"
- "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason"
- "dashoo.cn/backend/api/business/oilsupplier/tableheader"
- "dashoo.cn/backend/api/business/organize"
- "dashoo.cn/business2/parameter"
- "encoding/json"
- //"fmt"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
- "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
- // "dashoo.cn/backend/api/business/oilsupplier/technologyservice"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- )
- type OilSupplierCertSubController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []suppliercertsub.OilSupplierCertSub
- // @router /list [get]
- func (this *OilSupplierCertSubController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "CertSubStatus, Code"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierId := this.GetString("SupplierId")
- SupplierCertId := this.GetString("SupplierCertId")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- Code := this.GetString("Code")
- Name := this.GetString("Name")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierId != "" {
- where = where + " and SupplierId like '%" + SupplierId + "%'"
- }
- if SupplierCertId != "" {
- where = where + " and SupplierCertId = '" + SupplierCertId + "'"
- }
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- if Code != "" {
- where = where + " and Code like '" + Code + "%'"
- }
- if Name != "" {
- where = where + " and Name like '%" + Name + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- where = where + " and Type in (1, 3)"
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var list []suppliercertsub.OilSupplierCertSub
- total := svc.GetPagingEntitiesWithoutAccCode(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}
- // @router /listCert2019 [get]
- func (this *OilSupplierCertSubController) ListCert2019() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Name := this.GetString("Name")
- if Name != "" {
- where = where + " and (Name like '%" + Name + "%' or Code like '%" + Name + "%')"
- }
- where = where + " and Edition = '2'"
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var list []goodsaptitudeclass.OilGoodsAptitudeClass
- total := svc.GetPagingEntitiesWithoutAccCode(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} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilSupplierCertSubController) GetDictList() {
- dictList := make(map[string]interface{})
- //dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} suppliercertsub.OilSupplierCertSub
- // @router /get/:id [get]
- func (this *OilSupplierCertSubController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierCertSubName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilSupplierCertSubController) AddEntity() {
- var model suppliercertsub.OilSupplierCertSub
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- _, err := svc.InsertEntityBytbl(OilSupplierCertSubName, &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 /update/:id [post]
- func (this *OilSupplierCertSubController) UpdateEntity() {
- 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 suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(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{
- "Id",
- "SupplierId",
- "SupplierCertId",
- "SubClassId",
- "Code",
- "Name",
- "Remark",
- "IsDelete",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilSupplierCertSubName, 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 *OilSupplierCertSubController) 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 suppliercertsub.OilSupplierCertSub
- var entityempty suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertSubName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 批量添加准入范围--物资类
- // @Description 批量添加准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /check-certsub-lost [post]
- func (this *OilSupplierCertSubController) CheckCertSubLost () {
- 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 lostCertList []LostCertFiles
- // 查询出已有哪些资质
- supplierId := dataother.SupplierId
- supplierTypeCode := dataother.SupplierTypeCode
- var tableheaderList []supplierfile.OilSupplierFile
- fileSql := "SELECT * from OilSupplierFile WHERE SupplierId='" + strconv.Itoa(supplierId) + "'"
- fileSql += " AND (SupplierTypeCode='" + supplierTypeCode + "' or SupplierTypeCode='000')"
- svcHeader := tableheader.GetTableHeaderService(utils.DBE)
- svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
- var companyHasHeaders string
- for _, tableheader := range tableheaderList {
- companyHasHeaders += tableheader.NeedFileType + ","
- }
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
- //逐条检查需要的资质
- for n := 0; n < len(dataother.CheckList); n++ {
- if supplierModel.OperType == "制造商" {
- datamain.IsManufacturer = 1
- } else {
- datamain.IsManufacturer = 2
- }
- //检查是否资质全面
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, strconv.Itoa(datamain.IsManufacturer)) // 需要的资质
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- if supplierCertModel.InStyle == "4" {
- var needFile supplierfile.FileList
- //战略合作协议扫描件
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- if datamain.IsManufacturer == 1 { //制造商
- var needFile supplierfile.FileList
- // 中油集团公司产品质量认可证书
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
- needFile.FileName = CNPCrenkezhengshu
- needList = append(needList, needFile)
- }
- for _, needHeader := range needList {
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") &&
- strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
- //三证合一或五证合一的证件,不需要验证了
- continue
- }
- var fileist1 supplierfile.OilSupplierFile
- where1 := " SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "' and NeedFileType = '" + needHeader.FileName + "'"
- filesvc.GetEntityByWhere(OilSupplierFileName, where1, &fileist1)
- var filelist2 suppliercertappendsub.OilAppendChangeDetail
- where2 := " SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "' and NeedFileType = '" +needHeader.FileName + "'"
- svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService (utils.DBE)
- svc2.GetEntityByWhere(OilAppendChangeDetailName, where2, &filelist2)
- if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = dataother.CheckList[n].Code
- tmpLostCert.Name = dataother.CheckList[n].Name
- tmpLostCert.CertFileName = needHeader.FileName
- lostCertList = append(lostCertList, tmpLostCert)
- } else {
- if filelist2.FileName == "" && fileist1.FileName == "" {
- //缺少的资质
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = dataother.CheckList[n].Code
- tmpLostCert.Name = dataother.CheckList[n].Name
- tmpLostCert.CertFileName = needHeader.FileName
- lostCertList = append(lostCertList, tmpLostCert)
- }
- }
- }
- }
- var errinfo ErrorDataInfo
- if len(lostCertList) <= 0 {
- errinfo.Code = 0
- errinfo.Message = "验证通过!"
- this.Data["json"] = nil
- } else {
- errinfo.Code = -1
- errinfo.Message = "缺少资质!"
- this.Data["json"] = &lostCertList
- }
- this.ServeJSON()
- }
- // @Title 批量添加准入范围--物资类
- // @Description 批量添加准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /add-goods-certsub-filter [post]
- func (this *OilSupplierCertSubController) AddGoodsByFilter() {
- 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)
- // 查询出已有哪些资质
- supplierId := dataother.SupplierId
- supplierTypeCode := dataother.SupplierTypeCode
- var tableheaderList []supplierfile.OilSupplierFile
- fileSql := "SELECT * from OilSupplierFile WHERE SupplierId='" + strconv.Itoa(supplierId) + "'"
- fileSql += " AND (SupplierTypeCode='" + supplierTypeCode + "' or SupplierTypeCode='000')"
- svcHeader := tableheader.GetTableHeaderService(utils.DBE)
- svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
- var companyHasHeaders string
- for _, tableheader := range tableheaderList {
- companyHasHeaders += tableheader.NeedFileType + ","
- }
- var supplierModel supplier.OilSupplier
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- svcSupplier.GetEntityById(datamain.SupplierId, &supplierModel)
- // 记录缺少的证件
- invalidCertMsg := ""
- // 记录保存条数
- vaildCnt := 0
- //逐条检查需要的资质,符合才会保存
- for n := 0; n < len(dataother.CheckList); n++ {
- where_sub := "SupplierTypeCode = 01 and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- where_sub += " and SupplierCertId = '" + strconv.Itoa(dataother.SupplierCertId) + "'"
- where_sub += " and SubClassId = '" + dataother.CheckList[n].Id + "'"
- var model suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- has := svc.GetEntityByWhere(OilSupplierCertSubName, where_sub, &model)
- if !has {
- if supplierModel.OperType == "制造商" {
- datamain.IsManufacturer = 1
- } else {
- datamain.IsManufacturer = 2
- }
- //检查是否资质全面
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetGoodsNeedFileList(dataother.CheckList[n].Id, strconv.Itoa(datamain.IsManufacturer)) // 需要的资质
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- if supplierCertModel.InStyle == "4" {
- var needFile supplierfile.FileList
- //战略合作协议扫描件
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- if datamain.IsManufacturer == 1 { //制造商
- var needFile supplierfile.FileList
- // 中油集团公司产品质量认可证书
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
- needFile.FileName = CNPCrenkezhengshu
- needList = append(needList, needFile)
- }
- certsValid := true
- for _, needHeader := range needList {
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") &&
- strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
- //三证合一或五证合一的证件,不需要验证了
- continue
- }
- if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
- //缺少资质,不会保存
- invalidCertMsg += dataother.CheckList[n].Code + " " + dataother.CheckList[n].Name + "(缺少:" + needHeader.FileName + ") ,"
- certsValid = false
- break
- }
- }
- if !certsValid {
- //缺少资质,不会保存
- continue
- }
- datamain.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
- datamain.Code = dataother.CheckList[n].Code
- datamain.Name = dataother.CheckList[n].Name
- datamain.GoodsLevel = dataother.CheckList[n].GoodsLevel
- datamain.Remark = dataother.Remark
- datamain.IsDelete = 0
- datamain.CreateBy = this.User.Realname
- datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- unitsvc := organize.GetOrganizeService(utils.DBE)
- unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
- if unitid == "100000650" { // 100000650 企管法规处(内控与风险管理处)
- datamain.CertSubStatus = "1"
- }
- datamain.Id = 0
- //插入准入范围表
- svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
- // TODO: 删除准入范围和资质对应关系表
- //插入准入范围所需资质记录表
- /*for _, needHeader := range needList {
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") &&
- strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
- //三证合一或五证合一的证件,不需要保存
- continue
- }
- //加入对应表OilSupplierCert2File, 保存准入项所需的资质关系
- var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
- cert2File.SupplierId = dataother.SupplierId
- cert2File.SupplierCertId = dataother.SupplierCertId
- cert2File.SupplierCertSubId = datamain.Id
- cert2File.SupplierTypeCode = dataother.SupplierTypeCode
- cert2File.IsManuf = strconv.Itoa(datamain.IsManufacturer)
- cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
- cert2File.Code = dataother.CheckList[n].Code
- cert2File.Name = dataother.CheckList[n].Name
- cert2File.NeedFileType = needHeader.FileName
- svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
- }*/
- vaildCnt++
- }
- }
- var errinfo ErrorDataInfo
- if invalidCertMsg == "" {
- errinfo.Code = 0
- errinfo.Message = "操作成功!"
- } else if vaildCnt > 0 {
- errinfo.Code = -1
- errinfo.Message = "部分成功!" + invalidCertMsg
- } else {
- errinfo.Message = invalidCertMsg
- }
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 批量添加准入范围--技术服务类
- // @Description 批量添加准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /tech-cert-lost [post]
- func (this *OilSupplierCertSubController) CheckTechCertLost() {
- 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)
- var lostCertList []LostCertFiles
- for n := 0; n < len(dataother.CheckList); n++ {
- 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 fileist []supplierfile.OilSupplierFile
- where := "SupplierTypeCode in ('03','000') and SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "'"
- svcSupplier.GetEntitysByWhere(OilSupplierFileName, where, &fileist)
- var companyHasHeaders string
- for _, tableheader := range fileist {
- companyHasHeaders += tableheader.NeedFileType + ","
- }
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- 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
- }
- var fileist1 supplierfile.OilSupplierFile
- where1 := " SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "' and NeedFileType = '" + needList[i].FileName + "'"
- filesvc.GetEntityByWhere(OilSupplierFileName, where1, &fileist1)
- var filelist2 suppliercertappendsub.OilAppendChangeDetail
- where2 := " SupplierId = '" + strconv.Itoa(dataother.SupplierId) + "' and NeedFileType = '" + needList[i].FileName + "'"
- svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService (utils.DBE)
- svc2.GetEntityByWhere(OilAppendChangeDetailName, where2, &filelist2)
- if !strings.Contains(companyHasHeaders, needList[i].FileName+",") {
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = dataother.CheckList[n].Code
- tmpLostCert.Name = dataother.CheckList[n].Name
- tmpLostCert.CertFileName = needList[i].FileName
- lostCertList = append(lostCertList, tmpLostCert)
- } else {
- if filelist2.FileName == "" && fileist1.FileName == "" {
- //缺少的资质
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = dataother.CheckList[n].Code
- tmpLostCert.Name = dataother.CheckList[n].Name
- tmpLostCert.CertFileName = needList[i].FileName
- lostCertList = append(lostCertList, tmpLostCert)
- }
- }
- }
- }
- var errinfo ErrorDataInfo
- if len(lostCertList) <= 0 {
- errinfo.Code = 0
- errinfo.Message = "验证通过!"
- this.Data["json"] = nil
- } else {
- errinfo.Code = -1
- errinfo.Message = "缺少资质!"
- this.Data["json"] = &lostCertList
- }
- this.ServeJSON()
- }
- // @Title 批量添加准入范围--技术服务类
- // @Description 批量添加准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /addtechbus [post]
- func (this *OilSupplierCertSubController) AddTechBus() {
- //TODO: 没有像AddGoodsByFilter一样,保存时做合法性验证,因为在保存之前已经在前台调用了CheckTechCertLost验证过了,
- // 以后有时间再加上
- 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 {
- datamain.SubClassId = dataother.CheckList[n].Id
- datamain.Code = dataother.CheckList[n].Code
- datamain.Name = dataother.CheckList[n].Name
- datamain.Remark = dataother.Remark
- datamain.IsDelete = 0
- datamain.CreateBy = this.User.Realname
- datamain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- unitsvc := organize.GetOrganizeService(utils.DBE)
- unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
- if unitid == "100000650" {
- datamain.CertSubStatus = "1"
- }
- 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} lostCertList []LostCertFiles
- // @router /check-basis-lost [post]
- func (this *OilSupplierCertSubController) CheckBasisBusinessLost() {
- var model suppliercertsub.OilSupplierCertSub
- var err error
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- 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
- var lostCertList []LostCertFiles
- needList = filesvc.GetBasicNeedFileList(strconv.Itoa(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) + "'"
- svcCert.GetEntitysByWhere(OilSupplierFileName, where, &list)
- var companyHasHeaders string
- for _, tableheader := range list {
- companyHasHeaders += tableheader.NeedFileType + ","
- }
- //三证合一或五证合一不需要的字段
- 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 fileist1 supplierfile.OilSupplierFile
- where1 := " SupplierId = '" + strconv.Itoa(model.SupplierId) + "' and NeedFileType = '" + needList[i].FileName + "'"
- filesvc.GetEntityByWhere(OilSupplierFileName, where1, &fileist1)
- var filelist2 suppliercertappendsub.OilAppendChangeDetail
- where2 := " SupplierId = '" + strconv.Itoa(model.SupplierId) + "' and NeedFileType = '" + needList[i].FileName + "'"
- svc2 := suppliercertappendsub.GetOilSupplierCertAppendSubService (utils.DBE)
- svc2.GetEntityByWhere(OilAppendChangeDetailName, where2, &filelist2)
- if !strings.Contains(companyHasHeaders, needList[i].FileName+",") {
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = model.Code
- tmpLostCert.Name = model.Name
- tmpLostCert.CertFileName = needList[i].FileName
- lostCertList = append(lostCertList, tmpLostCert)
- } else {
- if filelist2.FileName == "" && fileist1.FileName == "" {
- //缺少的资质
- var tmpLostCert LostCertFiles
- tmpLostCert.Code = model.Code
- tmpLostCert.Name = model.Name
- tmpLostCert.CertFileName = needList[i].FileName
- lostCertList = append(lostCertList, tmpLostCert)
- }
- }
- }
- }
- var errinfo ErrorDataInfo
- if len(lostCertList) <= 0 {
- errinfo.Code = 0
- errinfo.Message = "验证通过!"
- this.Data["json"] = nil
- } else {
- errinfo.Code = -1
- errinfo.Message = "缺少资质!"
- this.Data["json"] = &lostCertList
- }
- this.ServeJSON()
- }
- // @Title 新增准入范围 --基建类
- // @Description 新增准入范围 --基建类
- // @Success 200 {object} controllers.Request
- // @router /addbusiness [post]
- func (this *OilSupplierCertSubController) AddBusiness() {
- 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()
- 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)
- unitsvc := organize.GetOrganizeService(utils.DBE)
- unitid := unitsvc.GetMyUnitDepartmentId(this.User.DepartmentId)
- if !has {
- //添加到准入分类表中
- if unitid == "100000095" {
- model.CertSubStatus = "1"
- }
- _, err = svc.InsertEntityBytbl(OilSupplierCertSubName, &model)
- } else {
- model.Id = submodel.Id
- }
- // 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} ErrorInfo
- // @Failure 403 :id 为空
- // @router /businessdelete/:Id [delete]
- func (this *OilSupplierCertSubController) BusinessDelete() {
- Id := this.Ctx.Input.Param(":Id")
- //SupplierCertId := this.GetString("SupplierCertId")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- //根据Id查出OilSupplierCertSub的SubClassId
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
- where := "delete from " + OilSupplierCertSubName + " where Id in (" + Id + ")" // 没有删除的准入范围
- svc.DBE.Exec(where)
- // TODO: 删除准入范围和资质对应关系表
- /*whereCert2File := "delete from " + OilSupplierCert2FileName + " where SupplierCertSubId in (" + Id + ")" // 没有删除的准入范围
- svc.DBE.Exec(whereCert2File)*/
- errinfo.Message = "删除成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 获取待审核业务列表
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /auditbuslist [get]
- func (this *OilSupplierCertSubController) AuditbusList() {
- var list []suppliercertsub.OilSupplierCertSub
- //获取分页信息
- page := this.GetPageInfoForm()
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- orderby := "CreateOn desc"
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop + " " + Order
- }
- where := "1 = 1"
- SupplierCertId := this.GetString("SupplierCertId")
- if SupplierCertId != "" {
- where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
- }
- total, list := svc.GetWaitAuditBusinesslist(page.CurrentPage, page.Size, orderby, OilSupplierCertSubName, OilClassOrgSettingName, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取审核意见列表
- // @Description 获取审核意见列表
- // @Success 200 {object} controllers.Request
- // @router /opinionlist [get]
- func (this *OilSupplierCertSubController) OpinionList() {
- SupplierCertSubId := this.GetString("SupplierCertSubId")
- var list []suppliercertsub.OilSupplierOpinion
- where := " 1 = 1 "
- if SupplierCertSubId != "" {
- where = where + " and SupplierCertSubId = '" + SupplierCertSubId + "'"
- }
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- svc.GetEntitysByWhere(OilSupplierOpinionName, where, &list)
- var datainfo DataInfo
- datainfo.Items = list
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 新增审核意见
- // @Description 新增审核意见
- // @Success 200 {object} controllers.Request
- // @router /addopinion [post]
- func (this *OilSupplierCertSubController) AddOpinion() {
- var model suppliercertsub.OilSupplierOpinion
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.AuditorName = this.User.Realname
- model.AuditorId, _ = utils.StrTo(this.User.Id).Int()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- //where := "SupplierCertSubId=" + strconv.Itoa(model.SupplierCertSubId) + " and AuditorId= " + strconv.Itoa(model.AuditorId) + " and Status = '" + model.Status + "'"
- //svc.DeleteEntityBytbl(OilSupplierOpinionName, where)
- _, err := svc.InsertEntityBytbl(OilSupplierOpinionName, &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
- // @router /updatestatus/:Id/:Status [get]
- func (this *OilSupplierCertSubController) UpdateStatus() {
- Id := this.Ctx.Input.Param(":Id")
- Status := this.Ctx.Input.Param(":Status")
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var error error
- if Status == "1" {
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='2' where Id=" + Id + "")
- } else {
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='1' 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
- // @router /modify-manufacturer/:id [post]
- func (this *OilSupplierCertSubController) SetManufacturer() {
- // certSubId, error := strconv.Atoi(this.Ctx.Input.Param(":id"))
- certSubId := this.Ctx.Input.Param(":id")
- var manufacturerChangeDTO suppliercertsub.ManufacturerChangeDTO
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &manufacturerChangeDTO)
- /**
- manufacturerChangeDTO.CertSubIdList = [] int{certSubId}
- invalidCertMsg := setManufacturerHandler(manufacturerChangeDTO)
- */
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- strIsManufacturer := strconv.Itoa(manufacturerChangeDTO.IsManufacturer)
- sqlStr := "update OilSupplierCertSub set IsManufacturer='" + strIsManufacturer + "' where Id='" + certSubId + "'"
- svc.DBE.Exec(sqlStr)
- var errinfo ErrorDataInfo
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- /*var errinfo ErrorDataInfo
- if error == nil && invalidCertMsg == "" {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + invalidCertMsg
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }*/
- }
- // @Title 批量修改是否为供应商
- // @Description
- // @router /modify-manufacturers/:certid [post]
- func (this *OilSupplierCertSubController) UpdateManufacturers() {
- certId := this.Ctx.Input.Param(":certid")
- var manufacturerChangeDTO suppliercertsub.ManufacturerChangeDTO
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &manufacturerChangeDTO)
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- strIsManufacturer := strconv.Itoa(manufacturerChangeDTO.IsManufacturer)
- sqlStr := "update OilSupplierCertSub set IsManufacturer='" + strIsManufacturer + "' where SupplierCertId='" + certId + "'"
- svc.DBE.Exec(sqlStr)
- var errinfo ErrorDataInfo
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- func setManufacturerHandler(manufacturerChangeDTO suppliercertsub.ManufacturerChangeDTO) (invalidCertMsg string) {
- CertSubIdList := manufacturerChangeDTO.CertSubIdList
- IsManufacturer := manufacturerChangeDTO.IsManufacturer
- SupplierId := manufacturerChangeDTO.SupplierId
- SupplierCertId := manufacturerChangeDTO.SupplierCertId
- //物资类
- SupplierTypeCode := "01"
- // 供应商主表
- svcSupplier := supplier.GetOilSupplierService(utils.DBE)
- var supplierEntity supplier.OilSupplier
- svcSupplier.GetEntityById(SupplierId, &supplierEntity)
- // 供应商准入申请表
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- var certEntity suppliercert.OilSupplierCert
- svcCert.GetEntityById(SupplierCertId, &certEntity)
- //------ 查询出企业已有哪些资质 Start------------
- var tableheaderList []supplierfile.OilSupplierFile
- fileSql := "SELECT * from OilSupplierFile WHERE SupplierId='" + strconv.Itoa(SupplierId) + "'"
- fileSql += " AND (SupplierTypeCode='" + SupplierTypeCode + "' or SupplierTypeCode='000')"
- svcHeader := supplierfile.GetSupplierfileService(utils.DBE)
- svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
- var companyHasHeaders string
- for _, tableheader := range tableheaderList {
- companyHasHeaders += tableheader.NeedFileType + ","
- }
- //------ 查询出企业已有哪些资质 End--------------
- for _, certSubId := range CertSubIdList {
- // 当前修改的记录
- var certSubEntity suppliercertsub.OilSupplierCertSub
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- svc.DBE.Where("Id=" + strconv.Itoa(certSubId)).Get(&certSubEntity)
- //--------------取出准入项需要的资质 Start--------------------------
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- needList := filesvc.GetGoodsNeedFileList(strconv.Itoa(certSubId), strconv.Itoa(IsManufacturer)) // 需要的资质
- //三证合一或五证合一不需要的字段
- mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
- if certEntity.InStyle == "4" {
- var needFile supplierfile.FileList
- //战略合作协议扫描件
- needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- needList = append(needList, needFile)
- }
- if certSubEntity.IsManufacturer == 1 { //制造商
- var needFile supplierfile.FileList
- // 中油集团公司产品质量认可证书
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
- needFile.FileName = CNPCrenkezhengshu
- needList = append(needList, needFile)
- }
- //--------------取出准入项需要的资质 End--------------------------
- //--------------检查是否符合资质 Start--------------------------
- certsValid := true
- for _, needHeader := range needList {
- if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
- strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
- //三证合一或五证合一的证件,不需要验证了
- continue
- }
- if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
- //缺少资质,不会保存
- invalidCertMsg += certSubEntity.Code + " " + certSubEntity.Name + "(缺少:" + needHeader.FileName + ") ,"
- certsValid = false
- break
- }
- }
- if !certsValid {
- //缺少资质,不能修改
- continue
- }
- //--------------检查是否符合资质 End--------------------------
- //修改状态
- certSubEntity.IsManufacturer = IsManufacturer
- svc.DBE.Where("Id=" + strconv.Itoa(certSubId)).Update(&certSubEntity)
- }
- return invalidCertMsg
- }
- // TODO: 删除准入范围和资质对应关系表
- /* type OilSupplierCert2File struct {
- Id int `json:"not null pk autoincr INT(10)"`
- certSubId int `json:"not null default 0 comment('供方基本信息表主键') INT(10)"`
- certSubStatus int `json:"not null default 0 comment('供方准入证书信息表主键') INT(10)"`
- stopReason string `json:"not null default '0' comment('准入类别代码(1 物资类,2 基建类,3 技术服务类)') VARCHAR(5)"`
- }*/
- type LostCertFiles struct {
- Code string
- Name string
- CertFileName string
- }
- // @Title 记录准入项状态更改日志
- // @Description
- // @router /updatestatuswithlog/:Id [post]
- func (this *OilSupplierCertSubController) UpdateStatusWithLog() {
- Id := this.Ctx.Input.Param(":Id")
- reasonSvc := supplierpausereason.GetOilSupplierPauseReasonService(utils.DBE)
- var pauseModel supplierpausereason.OilSupplierPauseReason
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &pauseModel)
- Status := pauseModel.CertSubStatus
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
- var error error
- if Status == "1" {
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='2' where Id=" + Id + "")
- pauseModel.CertSubStatus = "2"
- } else {
- _, error = svc.DBE.Exec("update " + OilSupplierCertSubName + " set CertSubStatus='1' where Id=" + Id + "")
- pauseModel.CertSubStatus = "1"
- }
- pauseModel.CreateOn = time.Now()
- pauseModel.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- pauseModel.CreateBy = this.User.Realname
- reasonSvc.InsertEntity(pauseModel)
- 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()
- }
- }
|