Преглед изворни кода

前后:信息变更审核通过后的操作;已入库列表查询优化;老数据导入

dubch пре 5 година
родитељ
комит
41d9e51f6d

+ 29 - 0
src/dashoo.cn/backend/api/business/oilsupplier/infochange/infochangeService.go

@@ -282,5 +282,34 @@ func (s *InfoChangeService) GetProcessInfoWithOrderBytbl(tableName string, pageI
 		}
 	}
 
+	return total
+}
+
+func (s *InfoChangeService) GetOldNameWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
+	var resultsSlice []map[string][]byte
+
+	//获取总记录数
+	sqlCount := `select count(*) from OilSupplierOldName where ` + where
+
+	var sql string
+	sql = `select Name as SupplierName, OldName as OldSupplierName from OilSupplierOldName where `+ where
+	if asc {
+		sql += ` order by ` + orderby + ` ASC `
+	} else {
+		sql += ` order by ` + orderby + ` DESC `
+	}
+	sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
+	s.DBE.SQL(sql).Find(entitiesPtr)
+
+	resultsSlice, _ = s.DBE.Query(sqlCount)
+
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total, _ = strconv.ParseInt(string(value), 10, 64)
+			break
+		}
+	}
+
 	return total
 }

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

@@ -496,6 +496,24 @@ type OilSupplierInte struct {
 	JSsub        []OilSupplierCertSubInte // 基建类
 }
 
+type OilCertIds struct {
+	Ids 		string
+}
+
+type OilSupplierOldName struct {
+	Id                  int       `xorm:"not null pk autoincr INT(11)"`
+	Name        		string    `xorm:"comment('企业名称') VARCHAR(255)"`
+	OldName        		string    `xorm:"comment('曾用名') VARCHAR(255)"`
+	SupplierId     		int    `xorm:" INT(11)"`
+	GfId    			int    `xorm:" INT(11)"`
+	CreateOn            time.Time `xorm:"DATETIME"`
+	CreateUserId        int       `xorm:"INT(10)"`
+	CreateBy            string    `xorm:"VARCHAR(50)"`
+	ModifiedOn          time.Time `xorm:"DATETIME"`
+	ModifiedUserId      int       `xorm:"INT(10)"`
+	ModifiedBy          string    `xorm:"VARCHAR(50)"`
+}
+
 const (
 	// 管理单位
 	MGRUNIT           string = "大港油田分公司"

+ 15 - 4
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -65,14 +65,16 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName
 
 	return total
 }
-func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl2(supplierTableName, supplierCertTableName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
+func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl2(supplierTableName, supplierCertTableName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string, code string, Ids string) (total int64) {
 	var resultsSlice []map[string][]byte
 
 	//获取总记录数
 	sqlCount := `select count(DISTINCT b.Id) from ` + supplierTableName + ` a `
 	sqlCount += ` left join ` + supplierCertTableName + " b on b.SupplierId = a.Id"
-	sqlCount += ` left join ` + "OilSupplierCertSub c on c.SupplierCertId = b.Id"
 	sqlCount += ` where ` + where
+	if code != "" {
+		sqlCount += ` and b.Id in (` + Ids + ")"
+	}
 
 	var sql string
 	sql = `select DISTINCT b.Id as CertId, a.*, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, b.InFlag, b.ApplyTime,b.EffectEndTime, `
@@ -90,8 +92,10 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl2(supplierTableNam
 	sql += ` b.WorkflowId, b.CreateOn ,b.ProcessKey,b.BusinessKey,b.BackRemark,b.IsRestrict`
 	sql += ` from ` + supplierTableName + ` a `
 	sql += ` left join ` + supplierCertTableName + " b on b.SupplierId = a.Id"
-	sql += ` left join ` + "OilSupplierCertSub c on c.SupplierCertId = b.Id"
 	sql += ` where ` + where
+	if code != "" {
+		sql += ` and b.Id in (` + Ids + ")"
+	}
 	if asc {
 		sql += ` order by ` + orderby + ` ASC `
 	} else {
@@ -337,4 +341,11 @@ func (s *OilSupplierService) GetProcessInfoWithOrderBytbl(supplierTableName, sup
 	}
 
 	return total
-}
+}
+
+func (s *OilSupplierService) GetCertIds( entitiesPtr interface{}, where string) {
+
+	sql := "SELECT GROUP_CONCAT(DISTINCT SupplierCertId) as Ids from OilSupplierCertSub where " + where + " ORDER BY SupplierCertId"
+
+	s.DBE.SQL(sql).Get(entitiesPtr)
+}

+ 2 - 2
src/dashoo.cn/backend/api/business/tmpzcgf/tmpzcgfSession.go

@@ -79,7 +79,7 @@ func (s *TmpzcgtSession) InsertSupplier() error {
 	OldSupplierName
 ) SELECT
 	max(企业名称) AS SupplierName,
-	max(级别) AS Grade,
+	IF(max(级别), IF(max(级别) = '一级', '1', '2'), '') AS Grade,
 	max(经营方式) AS OperType,
 	max(国家) AS Country,
 	max(所代理制造商名称) AS MaunAgent,
@@ -684,7 +684,7 @@ func (s *TmpzcgtSession) UpdateOilCatalog2() error {
 func (s *TmpzcgtSession) InsertOldName() error {
 	s.DBE.Query("SET unique_checks=0;")
 	// s.DBE.Query("SET autocommit=0;")
-	sql := "insert into OilSupplierOldName(OldName) select `曾用名` from `T_资格预审表` where 曾用名 is not null group by 曾用名"
+	sql := "insert into OilSupplierOldName(Name, OldName) select `企业名称`, `曾用名` from `T_资格预审表` where 曾用名 is not null group by 曾用名"
 	_, err := s.DBE.Query(sql)
 
 	// s.DBE.Query("commit;")

+ 6 - 6
src/dashoo.cn/backend/api/conf/app.conf

@@ -21,10 +21,10 @@ extranetIP = 60.30.245.229
 type=mysql
 
 #本地测试服务器
-name=supplier_system_test
-host=47.92.212.59
+name=supplier_system_20210107
+host=139.9.119.182
 user=root
-pwd=zks123456
+pwd=newsys*123
 #host=192.168.0.252
 #user=ixcell
 #pwd=ixcell123456
@@ -44,10 +44,10 @@ excelPassword = lims123456
 type=mysql
 
 #本地测试服务器
-name=casbin_test
-host=47.92.212.59
+name=casbin_20210107
+host=139.9.119.182
 user=root
-pwd=zks123456
+pwd=newsys*123
 domain=oil_supplier
 
 [workflow]

+ 159 - 133
src/dashoo.cn/backend/api/controllers/oilsupplier/infochange.go

@@ -426,32 +426,32 @@ func (this *InfoChangeController) GetAllEntityList() {
 	//获取分页信息
 	page := this.GetPageInfoForm()
 	where := " 1=1"
-	orderby := "a.Id"
+	orderby := "Id"
 	asc := false
 	Order := this.GetString("Order")
 	Prop := this.GetString("Prop")
 	SupplierId := this.GetString("SupplierId")
 	if Order != "" && Prop != "" {
-		orderby = "a." + Prop
+		orderby = Prop
 		if Order == "asc" {
 			asc = true
 		}
 	}
 
 	SupplierName := this.GetString("SupplierName")
-	if SupplierId != "" {
-		var model supplier.OilSupplier
-		sv := supplier.GetOilSupplierService(utils.DBE)
-		sv.GetEntityByIdBytbl(OilSupplierName, SupplierId, &model)
-		SupplierName = model.SupplierName
-	}
+	//if SupplierId != "" {
+	//	var model supplier.OilSupplier
+	//	sv := supplier.GetOilSupplierService(utils.DBE)
+	//	sv.GetEntityByIdBytbl(OilSupplierName, SupplierId, &model)
+	//	SupplierName = model.SupplierName
+	//}
 	CreateOn := this.GetString("CreateOn")
 
 	if SupplierName != "" {
-		where = where + " and a.SupplierName like '%" + SupplierName + "%'"
+		where = where + " and Name like '%" + SupplierName + "%'"
 	}
 	if SupplierId != "" {
-		where = where + " and b.SupplierId = '" + SupplierId + "'"
+		where = where + " and SupplierId = '" + SupplierId + "'"
 	}
 
 	if CreateOn != "" {
@@ -459,13 +459,14 @@ func (this *InfoChangeController) GetAllEntityList() {
 		if len(dates) == 2 {
 			minDate := dates[0]
 			maxDate := dates[1]
-			where = where + " and b.CreateOn>='" + minDate + "' and b.CreateOn<='" + maxDate + "'"
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
 		}
 	}
 
 	svc := infochange.GetInfoChangeService(utils.DBE)
 	var list []infochange.OilUsedName
-	total := svc.GetUsedNameWithOrderBytbl(OilSupplierName, OilInfoChangeItemName, page.CurrentPage, page.Size, orderby, asc, &list, where)
+	//total := svc.GetUsedNameWithOrderBytbl(OilSupplierName, OilInfoChangeItemName, page.CurrentPage, page.Size, orderby, asc, &list, where)
+	total := svc.GetOldNameWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where)
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total
@@ -1834,6 +1835,25 @@ func (this *InfoChangeController) CommonAuditEntity() {
 	infoSrv.GetEntityById(infoId, &infoChangeEntityAfterUpdate)
 	if infoChangeEntityAfterUpdate.Status == suppliercert.STORE_STATUS {
 		fmt.Println("资质变更入库完成, 开始实际变更信息: supplierId" + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId) + "变更信息表ID: " + infoId)
+		var oilSupplier supplier.OilSupplier
+		var oldName supplier.OilSupplierOldName
+		var info infochange.OilInfoChangeItem
+		svc := supplier.GetOilSupplierService(utils.DBE)
+		svc.GetEntityByWhere(OilInfoChangeItemName, "SelectItem = 'SupplierName' and InfoId = " + infoId, &info)
+		// 曾用名存到主表
+		oilSupplier.OldSupplierName = info.BeChangeInfo
+		svc.UpdateEntityBywheretbl(OilSupplierName, &oilSupplier, []string{"OldSupplierName"}, "Id = " + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId))
+
+		oldName.OldName = info.BeChangeInfo
+		oldName.Name = info.ChangeInfo
+		oldName.SupplierId = infoChangeEntityAfterUpdate.SupplierId
+		oldName.GfId = 0
+		oldName.CreateOn = info.CreateOn
+		oldName.CreateBy = info.CreateBy
+		oldName.CreateUserId = info.CreateUserId
+		// 曾用名存到子表
+		svc.InsertEntityBytbl("OilSupplierOldName", &oldName)
+
 		this.updateChangeInfo(infoChangeEntityAfterUpdate.SupplierId, infoId)
 	}
 }
@@ -1916,128 +1936,129 @@ func (this *InfoChangeController) updatesupplier(supname string, suppid int, inf
 }
 
 func (this *InfoChangeController) BusinessDelete(SupplierId string) {
-	SupplierTypeCode := "01"
-	var IsManufacturer string
+	//SupplierTypeCode := "01"
+	//var IsManufacturer string
 
 	//根据Id查出OilSupplierCertSub的SubClassId
 	svc := suppliercertsub.GetOilSupplierCertSubService(utils.DBE) //获得数据库引擎
-	filesvc := supplierfile.GetSupplierfileService(utils.DBE)
-	paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
+	//filesvc := supplierfile.GetSupplierfileService(utils.DBE)
+	//paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
 
-	var DelCertSublList []suppliercertsub.OilSupplierCertSub
+	//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 {
+	//svc.GetEntities(&DelCertSublList, whereDel)
+	svc.DeleteEntityBytbl(OilSupplierCertSubName, whereDel)
 
-			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条资质数据
-
-			}
-
-			// TODO: 删除准入范围和资质对应关系表
-			/*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单条准入范围
-
-		}
-	}
+	//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条资质数据
+	//
+	//		}
+	//
+	//		// TODO: 删除准入范围和资质对应关系表
+	//		/*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单条准入范围
+	//
+	//	}
+	//}
 }
 
 func (this *InfoChangeController) FileDelete(supplierId string) {
@@ -2076,24 +2097,29 @@ func (this *InfoChangeController) updateChangeInfo(supplierId int, infoId string
 	where = where + " and ChangeStatus = 0"
 
 	var supModel supplier.OilSupplier
+	svc := supplier.GetOilSupplierService(utils.DBE)
+	svc.GetEntitysByWhere(OilInfoChangeItemName, where, &infoItems)
+	//修改主表信息
 	this.updatesupplier(OilSupplierName, supplierId, infoItems, supModel)
 
-	// 级别 一级变二级 删除不符合的准入项和资质
+	// 级别 一级变二级 删除不符合的准入项
 	for _, item := range infoItems {
-		if item.SelectItem == "Grade" && (item.BeChangeInfo == "1" && item.ChangeInfo == "2") {
-			this.BusinessDelete(utils.ToStr(supplierId))
+		if item.SelectItem == "Grade" {
+			if item.BeChangeInfo == "1" && item.ChangeInfo == "2" {
+				this.BusinessDelete(utils.ToStr(supplierId))
+			}
 		}
 	}
 
-	// 删除资质及准入项
 	this.FileDelete(strconv.Itoa(supplierId))
 	t := time.Now()
 	s := time.Since(t)
 	log.Println(s, "============================")
 	var qualDetail []qualchange.OilQualChangeDetail
 	where1 := "SupplierId = " + utils.ToStr(supplierId) + " and ParentId=" + infoId
-	svc := infochange.GetInfoChangeService(utils.DBE)
-	svc.GetEntities(&qualDetail, where1)
+	svc1 := infochange.GetInfoChangeService(utils.DBE)
+	svc1.GetEntities(&qualDetail, where1)
+	//更新 变更的资质
 	if len(qualDetail) > 0 {
 		for i := 0; i < len(qualDetail); i++ {
 			var supFileModel supplierfile.OilSupplierFile

+ 7 - 4
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -864,9 +864,6 @@ func (this *OilSupplierController) GetJoinStoreEntityList() {
 	if InFlag != "" {
 		where = where + " and b.InFlag='" + InFlag + "'"
 	}
-	if Code != "" {
-		where = where + " and c.Code like '" + Code + "%'"
-	}
 
 	//企业用户只看自己的数据记录
 	/*parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
@@ -882,8 +879,14 @@ func (this *OilSupplierController) GetJoinStoreEntityList() {
 
 	svc := supplier.GetOilSupplierService(utils.DBE)
 	var list []supplier.OilSupplierView
+	var Ids supplier.OilCertIds
+
+	if Code != "" {
+		where1 := " SupplierTypeCode = '" + SupplierTypeCode + "' and Code like '" + Code + "%'"
+		svc.GetCertIds(&Ids, where1)
+	}
 
-	total := svc.GetMyPagingEntitiesWithOrderBytbl2(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
+	total := svc.GetMyPagingEntitiesWithOrderBytbl2(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where, Code, Ids.Ids)
 
 	var datainfo DataInfo
 	datainfo.Items = list