|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/infochange"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplier"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
|
|
|
"dashoo.cn/backend/api/business/register"
|
|
|
"dashoo.cn/business2/parameter"
|
|
|
@@ -1254,6 +1255,14 @@ func (this *InfoChangeController) InfoAudit() {
|
|
|
var supfilemodel supplierfile.OilSupplierFile
|
|
|
supfilemodel.SupType = 3
|
|
|
svc.UpdateEntityBywheretbl(OilSupplierFileName, &supfilemodel, []string{"SupType"}, where)
|
|
|
+
|
|
|
+ // 级别 一级变二级 删除不符合的准入项和资质
|
|
|
+ for _, item := range infoitems {
|
|
|
+ if item.SelectItem == "Grade" && (item.BeChangeInfo == "1" && item.ChangeInfo == "2") {
|
|
|
+ this.BusinessDelete(utils.ToStr(dataother.SuppId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//var qualdetail []qualchange.OilQualChangeDetail
|
|
|
//svc.UpdateEntityBytbl(OilSupplierFileName, qualdetail[i].FileId, &supfilemodel, []string{"SupType"})
|
|
|
//where := "SupplierId = " + utils.ToStr(dataother.SuppId)
|
|
|
@@ -1367,3 +1376,127 @@ func (this *InfoChangeController) updatesupplier(supname string, suppid int, inf
|
|
|
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+func (this *InfoChangeController) BusinessDelete(SupplierId string) {
|
|
|
+ SupplierTypeCode := "01"
|
|
|
+ var IsManufacturer string
|
|
|
+
|
|
|
+ //根据Id查出OilSupplierCertSub的SubClassId
|
|
|
+ svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
|
|
|
+ filesvc := supplierfile.GetSupplierfileService(utils.DBE)
|
|
|
+ paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+
|
|
|
+ var DelCertSublList []suppliercertsub.OilSupplierCertSub
|
|
|
+ // 级别 一级变二级 把物资类一级的删掉
|
|
|
+ whereDel := "SupplierId=" + SupplierId + " and SupplierTypeCode='01' and GoodsLevel='1'"
|
|
|
+ svc.GetEntities(&DelCertSublList, whereDel)
|
|
|
+
|
|
|
+ Id := ""
|
|
|
+ for _, item := range DelCertSublList {
|
|
|
+ Id = Id + "," + strconv.Itoa(item.Id)
|
|
|
+ }
|
|
|
+ Id = strings.Trim(Id,",")
|
|
|
+ if Id != "" {
|
|
|
+ Ids := strings.Split(Id, ",")
|
|
|
+
|
|
|
+ //
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ svc.DeleteEntityBytbl(OilSupplierFileName, where) //删除第j条资质数据
|
|
|
+
|
|
|
+ }
|
|
|
+ where = " SupplierId=" + strconv.Itoa(datamain.SupplierId) + " and SupplierTypeCode =" + SupplierTypeCode + " and SubClassId=" + strconv.Itoa(subClassId)
|
|
|
+ svc.DeleteEntityBytbl(OilSupplierCert2FileName, where)
|
|
|
+
|
|
|
+ where = " Id= " + Ids[i] + " and SupplierTypeCode =" + SupplierTypeCode
|
|
|
+ svc.DeleteEntityBytbl(OilSupplierCertSubName, where) //删除OilSupplierCertSub单条准入范围
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|