| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488 |
- 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/supplierpausereason"
- "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 := "Id"
- 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 /addgoodsbus [post]
- func (this *OilSupplierCertSubController) 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)
- 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 {
- 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 == "100000095" {
- datamain.CertSubStatus = "1"
- }
- svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
- 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.SupplierTypeCode = dataother.SupplierTypeCode
- cert2File.IsManuf = "2"
- cert2File.SubClassId, _ = utils.StrTo(dataother.CheckList[n].Id).Int()
- cert2File.Code = dataother.CheckList[n].Code
- cert2File.Name = dataother.CheckList[n].Name
- cert2File.NeedFileType = needList[i].FileName
- svc.InsertEntityBytbl(OilSupplierCert2FileName, &cert2File)
- if strings.Contains(mustField, needList[i].FileName+",") {
- entity.SupplierTypeCode = "000"
- entity.IsManuf = "0"
- } else {
- entity.SupplierTypeCode = dataother.SupplierTypeCode
- 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 = 1
- 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)
- }
- }
- }
- var errinfo ErrorDataInfo
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 批量添加准入范围--技术服务类
- // @Description 批量添加准入范围
- // @Success 200 {object} business.device.DeviceChannels
- // @router /addtechbus [post]
- func (this *OilSupplierCertSubController) 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 {
- 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 == "100000095" {
- datamain.CertSubStatus = "1"
- }
- svc.InsertEntityBytbl(OilSupplierCertSubName, &datamain)
- 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.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)
- if strings.Contains(mustField, needList[i].FileName+",") {
- entity.SupplierTypeCode = "000"
- } else {
- entity.SupplierTypeCode = dataother.SupplierTypeCode
- }
- 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 = 1
- 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)
- }
- }
- }
- var errinfo ErrorDataInfo
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- 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
- }
- 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++ {
- var entity supplierfile.OilSupplierFile
- entity.SupplierId = model.SupplierId
- //加入对应表OilSupplierCert2File
- var cert2File suppliercertsub.OilSupplierCert2File //创建结构体
- cert2File.SupplierId = model.SupplierId
- cert2File.SupplierCertId = model.SupplierCertId
- 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)
- if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(mergerCertSkipField, needList[i].FileName+",") { //三证合一或五证合一了
- continue
- }
- if strings.Contains(mustField, needList[i].FileName+",") {
- entity.SupplierTypeCode = "000"
- } else {
- entity.SupplierTypeCode = model.SupplierTypeCode
- }
- 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 = 1
- 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)
- }
- }
- 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")
- SupplierId := this.GetString("SupplierId")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- var IsManufacturer string
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- Ids := strings.Split(Id, ",")
- //根据Id查出OilSupplierCertSub的SubClassId
- svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
- filesvc := supplierfile.GetSupplierfileService(utils.DBE)
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- //
- var CertSublList []suppliercertsub.OilSupplierCertSub
- where := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode // 没有删除的准入范围
- svc.GetEntities(&CertSublList, where)
- SubClassIds := ""
- for _, CertSub := range CertSublList {
- SubClassIds += strconv.Itoa(CertSub.SubClassId) + ","
- }
- var SurplusList []supplierfile.FileList
- SubClassIds = strings.Trim(SubClassIds, ",")
- if SubClassIds != "" {
- if SupplierTypeCode == "01" {
- //SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds, IsManufacturer)
- } else if SupplierTypeCode == "02" {
- SurplusList = filesvc.GetBasicNeedFileList(SubClassIds)
- } else if SupplierTypeCode == "03" {
- SurplusList = filesvc.GetTechNeedFileList(SubClassIds)
- }
- }
- fileNames := ""
- for _, CertSub := range SurplusList {
- fileNames += CertSub.FileName + ","
- }
- for i := 0; i < len(Ids); i++ {
- IsManufacturer = filesvc.CheckIsManuf(Ids[i])
- if SubClassIds != "" {
- if SupplierTypeCode == "01" {
- var CertSublList2 []suppliercertsub.OilSupplierCertSub
- wheregood := "SupplierId=" + SupplierId + " and Id not in (" + Id + ") and SupplierTypeCode =" + SupplierTypeCode + " and IsManufacturer =" + IsManufacturer // 没有删除的准入范围
- svc.GetEntities(&CertSublList2, wheregood)
- SubClassIds2 := ""
- for _, CertSub := range CertSublList2 {
- SubClassIds2 += strconv.Itoa(CertSub.SubClassId) + ","
- }
- SubClassIds2 = strings.Trim(SubClassIds2, ",")
- SurplusList = filesvc.GetGoodsNeedFileList(SubClassIds2, IsManufacturer)
- }
- }
- if fileNames == "" {
- for _, CertSub := range SurplusList {
- fileNames += CertSub.FileName + ","
- }
- }
- var datamain suppliercertsub.OilSupplierCertSub //创建OilSupplierCertSub结构体(映射用)
- var datamain2 []suppliercertsub.OilSupplierCertSub //空的查询用
- where := " Id= " + Ids[i]
- svc.GetEntity(&datamain, where) //根据Id查找,映射结构体
- //再根据企业id查找这个企业有几个准入范围(如果只有一个准入范围了,基本资质也删除)
- supplierId := datamain.SupplierId
- where = "SupplierId=" + strconv.Itoa(supplierId)
- svc.GetEntities(&datamain2, where)
- flag := 0
- if len(datamain2) == 1 {
- flag = 1
- }
- subClassId := datamain.SubClassId //4.拿到结构体中的准入范围SubClassId
- //根据SubClassId查出此准入范围所拥有的资质名称
- var needList []supplierfile.FileList //定义存储所拥有资质名称的数组
- if datamain.SupplierTypeCode == "01" {
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), IsManufacturer) //通过准入范围Id获得资质名称并填充数组
- } else if datamain.SupplierTypeCode == "02" {
- needList = filesvc.GetBasicNeedFileList(strconv.Itoa(subClassId))
- } else {
- needList = filesvc.GetTechNeedFileList(strconv.Itoa(subClassId))
- }
- var mustField string
- mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
- //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
- for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
- if flag == 0 && strings.Contains(mustField, needList[j].FileName+",") {
- continue
- }
- if flag == 0 && strings.Contains(fileNames, needList[j].FileName+",") {
- continue
- }
- if datamain.SupplierTypeCode == "01" {
- where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and IsManuf='" + IsManufacturer + "' and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- } else {
- where = " SupplierId= '" + strconv.Itoa(datamain.SupplierId) + "' and SupplierTypeCode =" + SupplierTypeCode + " and NeedFileType='" + needList[j].FileName + "'" //拼接删除sql
- }
- 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()
- }
- }
- where = " SupplierId=" + strconv.Itoa(datamain.SupplierId) + " and SupplierTypeCode =" + SupplierTypeCode + " and SubClassId=" + strconv.Itoa(subClassId)
- err1 := svc.DeleteEntityBytbl(OilSupplierCert2FileName, where)
- if err1 == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err1.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- where = " Id= " + Ids[i] + " and SupplierTypeCode =" + SupplierTypeCode
- err2 := svc.DeleteEntityBytbl(OilSupplierCertSubName, where) //删除OilSupplierCertSub单条准入范围
- if err2 == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err2.Error())
- errinfo.Code = -1
- 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 /updatemanufacturer/:Id/:SupplierId/:IsManufacturer [get]
- func (this *OilSupplierCertSubController) UpdateManufacturer() {
- 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 = 1
- 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 = 1
- 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
- // @router /updatemanufacturers/:SupplierId/:IsManufacturer [get]
- func (this *OilSupplierCertSubController) UpdateManufacturers() {
- //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 CertSublListAll []suppliercertsub.OilSupplierCertSub
- wherea := "SupplierId=" + SupplierId + " and SupplierTypeCode='" + SupplierTypeCode + "' and IsManufacturer='1'"
- svc.GetEntities(&CertSublListAll, wherea)
- var error error
- for _, item := range CertSublListAll {
- Id := strconv.Itoa(item.Id)
- 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 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
- where1 := "SupplierTypeCode in (01,000) and IsManuf in ('0','2') and SupplierId =" + strconv.Itoa(supplierId)
- svc.GetEntitysByWhere(OilSupplierFileName, where1, &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 = 1
- 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()
- }
- }
- 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)"`
- }
- // @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()
- }
- }
|