浏览代码

后:查询哪些准入范围缺资质

wd 4 年之前
父节点
当前提交
64cb07fba1

+ 12 - 0
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -542,3 +542,15 @@ func (s *OilSupplierService) GetDeleteSub2(TableName, where string, entitiesPtr
 	sql += " set IsQuestion = 2, LackFile = concat(IFNULL(LackFile,''),',','" + name + "') where " + where
 	s.DBE.SQL(sql).Find(entitiesPtr)
 }
+
+func (s *OilSupplierService) GetDeleteSub3(TableName, where string, entitiesPtr interface{}, name string) {
+
+	sql := `update OilSupplierCertSub a `
+	if TableName == "OilBasisBuild" {
+		sql += ` left join ` + TableName + ` b on b.Id = a.SubClassId`
+	} else {
+		sql += ` left join ` + TableName + ` b on b.ClassId = a.SubClassId`
+	}
+	sql += " set IsQuestion1 = 3, LackFile1 = concat(IFNULL(LackFile1,''),',','" + name + "') where " + where
+	s.DBE.SQL(sql).Find(entitiesPtr)
+}

+ 17 - 15
src/dashoo.cn/backend/api/business/oilsupplier/suppliercertsub/oilsuppliercertsub.go

@@ -26,18 +26,20 @@ type OilSupplierCertSub struct {
 	ModifiedOn           time.Time `xorm:"DATETIME"`
 	ModifiedUserId       int       `xorm:"INT(10)"`
 	ModifiedBy           string    `xorm:"VARCHAR(50)"`
-	DueTime           	 time.Time `xorm:"DATETIME"`
+	DueTime              time.Time `xorm:"DATETIME"`
 	IsQuestion           int       `xorm:"default 0 comment('问题状态,0正常,1有问题') INT(10)"`
 	LackFile             string    `xorm:"default 0 comment('缺少资质') VARCHAR(500)"`
+	IsQuestion1          int       `xorm:"default 0 comment('问题状态,0正常,1有问题') INT(10)"`
+	LackFile1            string    `xorm:"default 0 comment('缺少资质') VARCHAR(500)"`
 }
 
 type OilSupplierCertSubSelect struct {
-	GoodsLevel           string    `xorm:"not null default '' comment('级别')"`
-	IsManufacturer       int       `xorm:"not null comment('是否为供应商') INT(11)"`
-	Code                 string    `xorm:"not null default '' comment('分类编码') VARCHAR(8)"`
-	Name                 string    `xorm:"not null default '' comment('分类名称') VARCHAR(50)"`
-	CertSubStatus        string    `xorm:"null default '1' comment('1:正常2:不良记录暂停') VARCHAR(10)"`
-	Remark               string    `xorm:"comment('备注') VARCHAR(500)"`
+	GoodsLevel     string `xorm:"not null default '' comment('级别')"`
+	IsManufacturer int    `xorm:"not null comment('是否为供应商') INT(11)"`
+	Code           string `xorm:"not null default '' comment('分类编码') VARCHAR(8)"`
+	Name           string `xorm:"not null default '' comment('分类名称') VARCHAR(50)"`
+	CertSubStatus  string `xorm:"null default '1' comment('1:正常2:不良记录暂停') VARCHAR(10)"`
+	Remark         string `xorm:"comment('备注') VARCHAR(500)"`
 }
 type OilSupplierCertSub1 struct {
 	Id                   int       `xorm:"not null pk autoincr INT(10)"`
@@ -61,12 +63,12 @@ type OilSupplierCertSub1 struct {
 	ModifiedOn           time.Time `xorm:"DATETIME"`
 	ModifiedUserId       int       `xorm:"INT(10)"`
 	ModifiedBy           string    `xorm:"VARCHAR(50)"`
-	DueTime           	 time.Time `xorm:"DATETIME"`
+	DueTime              time.Time `xorm:"DATETIME"`
 	HeaderCodes          string
-	Checked           	 int
+	Checked              int
 	HeaderName           string
 	MinClassId           string
-	IsQuestion		     string
+	IsQuestion           string
 }
 
 type Del_OilSupplierCertSub struct {
@@ -125,7 +127,7 @@ type goodsChecked struct {
 }
 type SupplierCertSubModel struct {
 	CheckList        []goodsChecked //批量添加准入范围
-	Id               int `xorm:"<- not null pk autoincr INT(10)"`
+	Id               int            `xorm:"<- not null pk autoincr INT(10)"`
 	SupplierId       int
 	SupplierCertId   int
 	SupplierTypeCode string
@@ -157,7 +159,7 @@ type techChecked struct {
 }
 type TechnologySubModel struct {
 	CheckList        []techChecked //批量添加准入范围
-	Id               int `xorm:"<- not null pk autoincr INT(10)"`
+	Id               int           `xorm:"<- not null pk autoincr INT(10)"`
 	SupplierId       int
 	SupplierCertId   int
 	SupplierTypeCode string
@@ -254,9 +256,9 @@ type OilCompare struct {
 	MoreInfo           string //备注
 	ManufacturerCode   string //代理的制造商编码
 	ManufacturerName   string //代理的制造商名称
-	Diff			   string //是否为比对出的不同项
+	Diff               string //是否为比对出的不同项
 }
 
 type Ids struct {
-	Id         string
-}
+	Id string
+}

+ 204 - 8
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -3836,14 +3836,16 @@ func (this *OilSupplierController) markLackCert(file supplierfile.CheckFile) {
 
 	// 查询出已有哪些资质
 	var tableheaderList []qualchange.OilQualChangeDetail1
-	//whereInfoFile := ""
-	//if file.CertId == "0" {
-	//	// 信息变更 不获取 增项和年审审核中的数据
-	//	whereInfoFile = " and SupType in (0,1,3,4,5)"
-	//} else {
-	//	whereInfoFile = " and SupType in (0,1,2,3,5)"
-	//}
-	fileSql := "SELECT * from OilSupplierFile WHERE SupplierId = " + strconv.Itoa(file.SupplierId)
+	where := ""
+	if file.CertId != "0" {
+		// 物资服务基建的资质分开判断 2021.06.07
+		var certInfo suppliercert.OilSupplierCert
+		supplierService.GetEntityByWhere("OilSupplierCert", "Id = "+file.CertId, &certInfo)
+		if certInfo.Id > 0 {
+			where = " and SupplierTypeCode in ( '000', '" + certInfo.SupplierTypeCode + "')"
+		}
+	}
+	fileSql := "SELECT * from OilSupplierFile WHERE IsDelete = 0 and SupplierId = " + strconv.Itoa(file.SupplierId) + where
 	svcHeader := tableheader.GetTableHeaderService(utils.DBE)
 	svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
 	var companyHasHeaders string
@@ -3972,6 +3974,160 @@ func (this *OilSupplierController) markLackCert(file supplierfile.CheckFile) {
 	}
 }
 
+func (this *OilSupplierController) markLackCertSub(file supplierfile.CheckFile) {
+	//获取主表信息
+	var supplierEntity supplier.OilSupplier
+	supplierService := supplier.GetOilSupplierService(utils.DBE)
+	supplierService.GetEntityById(file.SupplierId, &supplierEntity)
+	//获取准入信息表
+	var certList []suppliercert.OilSupplierCert
+	supplierService.GetEntitysByWhere("OilSupplierCert", "SupplierId = "+strconv.Itoa(file.SupplierId), &certList)
+	certsubService := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
+
+	// 查询出已有哪些资质
+	var tableheaderList []qualchange.OilQualChangeDetail1
+	where := ""
+	if file.CertId != "0" {
+		// 物资服务基建的资质分开判断 2021.06.07
+		var certInfo suppliercert.OilSupplierCert
+		supplierService.GetEntityByWhere("OilSupplierCert", "Id = "+file.CertId, &certInfo)
+		if certInfo.Id > 0 {
+			where = " and SupplierTypeCode in ( '000', '" + certInfo.SupplierTypeCode + "')"
+		}
+	}
+	fileSql := "SELECT * from OilSupplierFile WHERE IsDelete = 0 and SupplierId = " + strconv.Itoa(file.SupplierId) + where
+	svcHeader := tableheader.GetTableHeaderService(utils.DBE)
+	svcHeader.DBE.SQL(fileSql).Find(&tableheaderList)
+	var companyHasHeaders string
+	for _, tableheader := range tableheaderList {
+		companyHasHeaders += tableheader.NeedFileType + ","
+	}
+	paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
+	filesvc := supplierfile.GetSupplierfileService(utils.DBE)
+	mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName")
+
+	for _, cert := range certList {
+		if file.CertId != "0" && strconv.Itoa(cert.Id) != file.CertId {
+			continue
+		}
+
+		//对准入范围的判断
+		var certSubList []suppliercertsub.OilSupplierCertSub
+		certsubService.GetListByCertId(strconv.Itoa(cert.Id), &certSubList)
+		certsubService.GetEntitysByWhere(OilSupplierCertSubName, "SupplierCertId = "+strconv.Itoa(cert.Id), &certSubList)
+		idString := ""
+		idString1 := ""
+		for i := 0; i < len(certSubList); i = i + 1000 {
+			var ids suppliercertsub.Ids
+			certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 3, strconv.Itoa(i))
+			if ids.Id != "" {
+				idString += "," + ids.Id
+			} else {
+				break
+			}
+		}
+		var needList []supplierfile.FileList
+		var needList1 []supplierfile.FileList
+
+		if cert.SupplierTypeCode == "01" {
+			//需要的资质
+			needList1 = filesvc.GetGoodsNeedFileListNew(idString, "2")
+			if file.Type == 1 { //制造商
+				//如果是制造商,准入范围按照各项准入范围的类型判断
+				// 制造
+				idString = ""
+				for i := 0; i < len(certSubList); i = i + 1000 {
+					var ids suppliercertsub.Ids
+					certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids, 1, strconv.Itoa(i))
+					if ids.Id != "" {
+						idString += "," + ids.Id
+					} else {
+						break
+					}
+				}
+				// 非制造
+				for i := 0; i < len(certSubList); i = i + 1000 {
+					var ids1 suppliercertsub.Ids
+					certsubService.GetIds(strconv.Itoa(cert.Id), cert.SupplierTypeCode, &ids1, 2, strconv.Itoa(i))
+					if ids1.Id != "" {
+						idString1 += "," + ids1.Id
+					} else {
+						break
+					}
+				}
+				needList = filesvc.GetGoodsNeedFileListNew(idString, "1")
+				needList1 = filesvc.GetGoodsNeedFileListNew(idString1, "2")
+			}
+		} else if cert.SupplierTypeCode == "02" {
+			needList = filesvc.GetBasicNeedFileListNew(idString)
+		} else if cert.SupplierTypeCode == "03" {
+			needList = filesvc.GetTechNeedFileListNew(idString)
+		}
+
+		for _, needHeader := range needList {
+			if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
+				strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
+				//三证合一或五证合一的证件,不需要验证了
+				continue
+			}
+
+			if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
+				var header tableheader.BaseTableheader
+				where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
+				if cert.SupplierTypeCode == "01" {
+					where1 += " and IsManuf != '2'"
+				}
+				supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
+				if header.Code != "" {
+					where2 := header.Code + " = '1'"
+					where2 += " and a.SupplierId = " + strconv.Itoa(supplierEntity.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
+
+					var certSub []suppliercertsub.OilSupplierCertSub
+					if cert.SupplierTypeCode == "01" {
+						where2 += " and IsManufacturer != 2"
+						supplierService.GetDeleteSub3(OilGoodsAptitudeName, where2, &certSub, header.Name)
+					} else if cert.SupplierTypeCode == "02" {
+						supplierService.GetDeleteSub3(OilBasisBuildName, where2, &certSub, header.Name)
+					} else {
+						supplierService.GetDeleteSub3(OilTechnologyServiceName, where2, &certSub, header.Name)
+					}
+				} else {
+					fmt.Print("22222")
+				}
+			}
+		}
+		for _, needHeader := range needList1 {
+			// 非制造
+			if (supplierEntity.CredentialFlag == "1" || supplierEntity.CredentialFlag == "2") &&
+				strings.Contains(mergerCertSkipField, needHeader.FileName+",") {
+				//三证合一或五证合一的证件,不需要验证了
+				continue
+			}
+
+			if !strings.Contains(companyHasHeaders, needHeader.FileName+",") {
+				var header tableheader.BaseTableheader
+				where1 := "Name = '" + needHeader.FileName + "' and CategoryCode = '" + cert.SupplierTypeCode + "'"
+				if cert.SupplierTypeCode == "01" {
+					where1 += " and IsManuf != '1'"
+				}
+				supplierService.GetEntityByWhere(BaseTableHeader, where1, &header)
+				if header.Code != "" {
+					where2 := header.Code + " = '1'"
+					where2 += " and a.SupplierId = " + strconv.Itoa(supplierEntity.Id) + " and a.SupplierTypeCode = '" + cert.SupplierTypeCode + "'"
+					var certSub []suppliercertsub.OilSupplierCertSub
+					if file.Type == 1 {
+						where2 += " and IsManufacturer = 2"
+					}
+					supplierService.GetDeleteSub3(OilGoodsAptitudeName, where2, &certSub, header.Name)
+				} else {
+					fmt.Print("22222")
+				}
+			}
+		}
+
+	}
+}
+
 // @Title 对外-招投标系统
 // @Description
 // @Success 200 {object}
@@ -4076,3 +4232,43 @@ func (this *OilSupplierController) GetLackCertList() {
 		}
 	}
 }
+
+// @Title 获取所有缺资质的准入范围
+// @Description
+// @Success 200 {object}
+// @router /lackCertSubList [get]
+func (this *OilSupplierController) GetLackCertSubList() {
+	secret := this.GetString("secret")
+	if secret != "scgl-lack-moral" {
+		return
+	}
+	supService := supplier.GetOilSupplierService(utils.DBE)
+	var supEntity supplier.OilSupplier
+	certService := suppliercert.GetOilSupplierCertService(utils.DBE)
+	var allCertList []suppliercert.OilSupplierCert
+	whereCert := " Status = '8' or Status = '11' "
+	certService.GetEntitysByWhere(OilSupplierCertName, whereCert, &allCertList)
+	if len(allCertList) > 0 {
+		// 重置标识
+		sql := "update " + OilSupplierCertSubName + " set LackFile1 = '',IsQuestion1 = 0 "
+		_, _ = certService.DBE.Exec(sql)
+		log.Println("共查询到准入条数:", len(allCertList))
+		for _, certEntity := range allCertList {
+			supService.GetEntityById(certEntity.SupplierId, &supEntity)
+			var file supplierfile.CheckFile
+			file.CertId = strconv.Itoa(certEntity.Id)
+			file.SupplierId = certEntity.SupplierId
+			file.Grade = supEntity.Grade
+			if supEntity.OperType == "制造商" {
+				file.Type = 1
+			}
+			if supEntity.OperType == "贸易商" || supEntity.OperType == "代理商" {
+				file.Type = 2
+			}
+			// 其他字段值
+			this.markLackCertSub(file)
+			log.Println("标记准入缺资质")
+		}
+	}
+	log.Println("结束")
+}