|
|
@@ -550,7 +550,7 @@ func (this *OilSupplierCertSubController) AddGoodsByFilter() {
|
|
|
needFile.FileName = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
|
|
|
needList = append(needList, needFile)
|
|
|
}
|
|
|
- if datamain.IsManufacturer == 2 { //非制造商
|
|
|
+ if datamain.IsManufacturer == 1 { //制造商
|
|
|
var needFile supplierfile.FileList
|
|
|
// 中油集团公司产品质量认可证书
|
|
|
CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
@@ -1112,816 +1112,153 @@ func (this *OilSupplierCertSubController) UpdateStatus() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// @Title 批量修改是否为制造商
|
|
|
-// Update by wanglin 7-11
|
|
|
-// @Description
|
|
|
-// @router /updatemanufacturer/:Id/:SupplierId/:IsManufacturer [get]
|
|
|
-func (this *OilSupplierCertSubController) SetManufacturer() {
|
|
|
- Ids := 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 (" + Ids + ") 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 (" + Ids + ") 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
|
|
|
- where = " Id in( " + Ids + ") "
|
|
|
-
|
|
|
- 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 in (" + Ids + ")")
|
|
|
- } 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 (" + Ids + ") 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 in( " + Ids + ") "
|
|
|
- //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获得资质名称并填充数组
|
|
|
-
|
|
|
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
- for _, item := range needList {
|
|
|
- if CNPCrenkezhengshu == item.FileName {
|
|
|
- errinfo.Message = "该准入项不能修改为非制造类!"
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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 in(" + Ids + ")")
|
|
|
- }
|
|
|
-
|
|
|
- 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获得资质名称并填充数组
|
|
|
-
|
|
|
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
- for _, item := range needList {
|
|
|
- if CNPCrenkezhengshu == item.FileName {
|
|
|
- errinfo.Message = "该准入项不能修改为非制造类!"
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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
|
|
|
+// @Title 修改是否为供应商
|
|
|
+// @Description
|
|
|
+// @router /modify-manufacturer/:id [post]
|
|
|
+func (this *OilSupplierCertSubController) SetManufacturer() {
|
|
|
+ certSubId, error := strconv.Atoi(this.Ctx.Input.Param(":id"))
|
|
|
|
|
|
- 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
|
|
|
+ var manufacturerChangeDTO suppliercertsub.ManufacturerChangeDTO
|
|
|
+ var jsonblob = this.Ctx.Input.RequestBody
|
|
|
+ json.Unmarshal(jsonblob, &manufacturerChangeDTO)
|
|
|
|
|
|
- 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 + "")
|
|
|
- }
|
|
|
+ manufacturerChangeDTO.CertSubIdList = [] int{certSubId}
|
|
|
+ invalidCertMsg := setManufacturerHandler(manufacturerChangeDTO)
|
|
|
|
|
|
var errinfo ErrorDataInfo
|
|
|
- if error == nil {
|
|
|
+ if error == nil && invalidCertMsg == "" {
|
|
|
errinfo.Message = "修改成功!"
|
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
} else {
|
|
|
- errinfo.Message = "修改失败!"
|
|
|
+ errinfo.Message = "修改失败!" + invalidCertMsg
|
|
|
errinfo.Code = -1
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// @Title 修改是否为供应商
|
|
|
+// @Title 批量修改是否为供应商
|
|
|
// @Description
|
|
|
-// @router /updatemanufacturers/:SupplierId/:IsManufacturer [get]
|
|
|
+// @router /modify-manufacturers/:certid [post]
|
|
|
func (this *OilSupplierCertSubController) UpdateManufacturers() {
|
|
|
- //Id := this.Ctx.Input.Param(":Id")
|
|
|
- IsManufacturer := this.Ctx.Input.Param(":IsManufacturer")
|
|
|
- SupplierId := this.Ctx.Input.Param(":SupplierId")
|
|
|
- SupplierTypeCode := "01"
|
|
|
+ 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)
|
|
|
var CertSublListAll []suppliercertsub.OilSupplierCertSub
|
|
|
- wherea := "SupplierId=" + SupplierId + " and SupplierTypeCode='" + SupplierTypeCode + "' and IsManufacturer='1'"
|
|
|
- svc.GetEntities(&CertSublListAll, wherea)
|
|
|
-
|
|
|
- var error error
|
|
|
-LABEL1:
|
|
|
- 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获得资质名称并填充数组
|
|
|
+ where := "SupplierCertId=" + certId
|
|
|
+ svc.GetEntities(&CertSublListAll, where)
|
|
|
+ certSubIdList := []int{}
|
|
|
+ for _, certSub := range CertSublListAll {
|
|
|
+ certSubIdList = append(certSubIdList, certSub.Id)
|
|
|
+ }
|
|
|
+ manufacturerChangeDTO.CertSubIdList = certSubIdList
|
|
|
+ invalidCertMsg := setManufacturerHandler(manufacturerChangeDTO)
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if 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()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- var mustField string
|
|
|
- mustField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MustFieldName") //必需的资质
|
|
|
+func setManufacturerHandler (manufacturerChangeDTO suppliercertsub.ManufacturerChangeDTO) (invalidCertMsg string) {
|
|
|
+ CertSubIdList := manufacturerChangeDTO.CertSubIdList
|
|
|
+ IsManufacturer := manufacturerChangeDTO.IsManufacturer
|
|
|
+ SupplierId := manufacturerChangeDTO.SupplierId
|
|
|
+ SupplierCertId := manufacturerChangeDTO.SupplierCertId
|
|
|
+ //物资类
|
|
|
+ SupplierTypeCode := "01"
|
|
|
|
|
|
- //根据企业ID(SupplierId)和此准入范围所拥有的资质名称删除OilSupplierFile表中对应的资质
|
|
|
- for j := 0; j < len(needList); j++ { //循环遍历资质名称数组,逐条删除
|
|
|
+ // 供应商主表
|
|
|
+ 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)
|
|
|
|
|
|
- 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()
|
|
|
- }
|
|
|
- }
|
|
|
+ //------ 查询出企业已有哪些资质 Start------------
|
|
|
+ var tableheaderList []tableheader.BaseTableheader
|
|
|
+ fileSql := "SELECT b.* from OilSupplierFile a LEFT JOIN Base_TableHeader b on a.NeedFileType=b.Name AND "
|
|
|
+ fileSql += " a.SupplierTypeCode=b.CategoryCode WHERE a.SupplierId='" + strconv.Itoa(SupplierId) + "'"
|
|
|
+ fileSql += " AND (a.SupplierTypeCode='" + SupplierTypeCode + "' or a.SupplierTypeCode='000')"
|
|
|
+ svcHeader := tableheader.GetTableHeaderService(utils.DBE)
|
|
|
+ svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
|
|
|
+ var companyHasHeaders string
|
|
|
+ for _, tableheader := range tableheaderList {
|
|
|
+ companyHasHeaders += tableheader.Name + ","
|
|
|
+ }
|
|
|
+ //------ 查询出企业已有哪些资质 End--------------
|
|
|
|
|
|
- CNPCrenkezhengshu := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CNPCrenkezhengshu")
|
|
|
- for _, item := range needList {
|
|
|
- if CNPCrenkezhengshu == item.FileName {
|
|
|
- where := "Id=" + Id
|
|
|
- svc.DeleteEntityBytbl(OilSupplierCertSubName, where)
|
|
|
- continue LABEL1
|
|
|
- }
|
|
|
- }
|
|
|
+ for _, certSubId := range CertSubIdList {
|
|
|
+ // 当前修改的记录
|
|
|
+ var certSubEntity suppliercertsub.OilSupplierCertSub
|
|
|
+ svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
|
|
|
+ svc.DBE.Where("Id="+ strconv.Itoa(certSubId)).Get(&certSubEntity)
|
|
|
|
|
|
- needList = filesvc.GetGoodsNeedFileList(strconv.Itoa(subClassId), "2")
|
|
|
- if supplierCertModel.InStyle == "4" {
|
|
|
+ //--------------取出准入项需要的资质 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)
|
|
|
}
|
|
|
-
|
|
|
- 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+",") { //三证合一或五证合一了
|
|
|
+ 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
|
|
|
}
|
|
|
- //加入对应表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
|
|
|
+ if !strings.Contains(companyHasHeaders, needHeader.FileName + ",") {
|
|
|
+ //缺少资质,不会保存
|
|
|
+ invalidCertMsg += certSubEntity.Code + " " + certSubEntity.Name + "(缺少:" + needHeader.FileName + ") ,"
|
|
|
+ certsValid = false
|
|
|
+ break
|
|
|
}
|
|
|
- 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()
|
|
|
+ if !certsValid {
|
|
|
+ //缺少资质,不能修改
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //--------------检查是否符合资质 End--------------------------
|
|
|
+ //修改状态
|
|
|
+ certSubEntity.IsManufacturer = IsManufacturer
|
|
|
+ svc.DBE.Where("Id="+ strconv.Itoa(certSubId)).Update(&certSubEntity)
|
|
|
}
|
|
|
+ return invalidCertMsg
|
|
|
}
|
|
|
|
|
|
+
|
|
|
type OilSupplierCert2File struct {
|
|
|
Id int `json:"not null pk autoincr INT(10)"`
|
|
|
certSubId int `json:"not null default 0 comment('供方基本信息表主键') INT(10)"`
|