Explorar o código

后:供方信息查询优化

dubch %!s(int64=5) %!d(string=hai) anos
pai
achega
9fba16cd43

+ 5 - 5
src/dashoo.cn/backend/api/business/oilsupplier/selectbusiness/selectservice.go

@@ -21,7 +21,7 @@ func GetSelectService(xormEngine *xorm.Engine) *SelectService {
 }
 
 func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, supplierCertTableName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
-	OilSupplierFileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where,having, liftjoon string) (total int64) {
+	OilSupplierFileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where,having, CerSubName string, Ids string) (total int64) {
 
 	//获取总记录数
 	/*sqlCount := `select count(*) from (`
@@ -44,18 +44,18 @@ func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, sup
 	sql += `a.LinkAddress,a.LinkProvince,a.LinkCity,a.LinkStreet,a.BusinessScope, `
 	sql += `b.InStyle, b.Id CertId, f.FullName, b.RecUnitName as CheckUnitName, b.Remark, `
 	sql += `group_concat(distinct e.NeedFileType) NeedFileType `
-	if liftjoon != "" {
-		sql += `,group_concat(distinct d.Name) CerSubName `
-	}
 	sql += `from ` + supplierTableName + ` a `
 	sql += `left join ` + supplierCertTableName + ` b on b.SupplierId = a.Id `
 	sql += `left join  Base_Organize f on f.Id = b.ThirdAudit `
 	// sql += `left join  OilCorporateInfo g on g.CommercialNo = a.CommercialNo `
 	// sql += `left join ` + OilInfoChangeName + ` c  on c.SupplierId = a.Id `
-	sql += liftjoon
 	sql += `left join ` + OilSupplierFileName + ` e  on e.SupplierId = a.Id `
 	sql += `where ` + where
 
+	if CerSubName != "" && Ids != "" {
+		sql += " and b.Id in (" + Ids + ")"
+	}
+
 	sql += ` group by a.Id,b.Id ` + having
 	if asc {
 		sql += ` order by ` + orderby + ` ASC `

+ 10 - 13
src/dashoo.cn/backend/api/controllers/oilsupplier/select.go

@@ -91,7 +91,7 @@ func (this *SelectController) GetTList() {
 			asc = false
 		}
 	}
-	leftjoin := ""
+
 	//准入证号
 	if model.AccessCardNo != "" {
 		where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'"
@@ -235,34 +235,31 @@ func (this *SelectController) GetTList() {
 	} else {
 		CerSubName = strings.Split(model.CerSubName, ",")
 	}
-
+	var Ids supplier.OilCertIds
 	//准入范围
 	if model.CerSubName != "" {
+		svc := supplier.GetOilSupplierService(utils.DBE)
+		where1 := ""
 		for key, value := range CerSubName {
 			if key == 0 {
-				where += " and (d.Name like '%" + value + "%' "
+				where1 += " (Name like '%" + value + "%' "
 			} else {
-				where += "or d.Name like '%" + value + "%' "
+				where1 += "or Name like '%" + value + "%' "
 			}
 		}
-		where += ") "
-		//having = " having CerSubName like '%" + model.CerSubName + "%' "
-		leftjoin = "left join " + OilSupplierCertSubName + " d  on d.SupplierCertId = b.Id "
+		where1 += ") "
+		svc.GetCertIds(&Ids, where1)
 	}
 	//资质
 	if model.NeedFileType != "" {
 		having = " having NeedFileType like '%" + model.NeedFileType + "%' "
 	}
-	if model.CerSubName != "" && model.NeedFileType != "" {
-		//having = " having CerSubName like '%" + model.CerSubName + "%' and  NeedFileType like '%" + model.NeedFileType + "%' "
-		having = " having NeedFileType like '%" + model.NeedFileType + "%' "
-		leftjoin = "left join " + OilSupplierCertSubName + " d  on d.SupplierCertId = b.Id "
-	}
+
 	svc := selectbusiness.GetSelectService(utils.DBE)
 	var list []supplier.OilSupplierSelect
 
 	total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName,
-		OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin)
+		OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, model.CerSubName, Ids.Ids)
 
 	var datainfo DataInfo
 	datainfo.Items = list