|
|
@@ -219,7 +219,7 @@ func (s *OilGoodsAptitudeService) InsertTmpGoodsAptitude(parentId, fcode, val st
|
|
|
}
|
|
|
|
|
|
func (s *OilGoodsAptitudeService) GetPagingCheckedEntities(pageIndex, itemsPerPage int64, orderby string,
|
|
|
- asc bool, entitiesPtr interface{}, having string) (total int64) {
|
|
|
+ asc bool, entitiesPtr interface{}, where string) (total int64) {
|
|
|
|
|
|
var sql string
|
|
|
sql = `SELECT
|
|
|
@@ -283,62 +283,64 @@ func (s *OilGoodsAptitudeService) GetPagingCheckedEntities(pageIndex, itemsPerPa
|
|
|
max(goods.F46) AS F46,
|
|
|
|
|
|
(
|
|
|
- if((max(goods.F01)='1' AND LOCATE('F01', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F02)='1' AND LOCATE('F02', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F03)='1' AND LOCATE('F03', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F04)='1' AND LOCATE('F04', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F05)='1' AND LOCATE('F05', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F06)='1' AND LOCATE('F06', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F07)='1' AND LOCATE('F07', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F08)='1' AND LOCATE('F08', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F09)='1' AND LOCATE('F09', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F10)='1' AND LOCATE('F10', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F11)='1' AND LOCATE('F12', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F13)='1' AND LOCATE('F13', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F14)='1' AND LOCATE('F14', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F15)='1' AND LOCATE('F15', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F16)='1' AND LOCATE('F16', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F17)='1' AND LOCATE('F17', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F18)='1' AND LOCATE('F18', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F19)='1' AND LOCATE('F19', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F20)='1' AND LOCATE('F20', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F21)='1' AND LOCATE('F21', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F22)='1' AND LOCATE('F22', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F23)='1' AND LOCATE('F23', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F24)='1' AND LOCATE('F24', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F25)='1' AND LOCATE('F25', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F26)='1' AND LOCATE('F26', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F27)='1' AND LOCATE('F27', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F28)='1' AND LOCATE('F28', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F29)='1' AND LOCATE('F29', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F30)='1' AND LOCATE('F30', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F31)='1' AND LOCATE('F31', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F32)='1' AND LOCATE('F32', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F33)='1' AND LOCATE('F33', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F34)='1' AND LOCATE('F34', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F35)='1' AND LOCATE('F35', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F36)='1' AND LOCATE('F36', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F37)='1' AND LOCATE('F37', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F38)='1' AND LOCATE('F38', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F39)='1' AND LOCATE('F39', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F40)='1' AND LOCATE('F40', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F41)='1' AND LOCATE('F41', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F42)='1' AND LOCATE('F42', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F43)='1' AND LOCATE('F43', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F44)='1' AND LOCATE('F44', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F45)='1' AND LOCATE('F45', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE) AND
|
|
|
- if((max(goods.F46)='1' AND LOCATE('F46', group_concat(DISTINCT header.Code)) > 0), TRUE, FALSE)
|
|
|
- ) AS checked
|
|
|
+ ((if((max(goods.F01)='1' AND LOCATE('F01', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F01) is null) or (max(goods.F01) = ''), TRUE, FALSE)) or
|
|
|
+ (if((max(goods.F36)='1' AND LOCATE('F36', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F36) is null) or (max(goods.F36) = ''), TRUE, FALSE)) or
|
|
|
+ (if((max(goods.F37)='1' AND LOCATE('F37', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F37) is null) or (max(goods.F37) = ''), TRUE, FALSE))) AND
|
|
|
+ if((max(goods.F02)='1' AND LOCATE('F02', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F02) is null) or (max(goods.F02) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F03)='1' AND LOCATE('F03', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F03) is null) or (max(goods.F03) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F04)='1' AND LOCATE('F04', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F04) is null) or (max(goods.F04) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F05)='1' AND LOCATE('F05', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F05) is null) or (max(goods.F05) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F06)='1' AND LOCATE('F06', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F06) is null) or (max(goods.F06) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F07)='1' AND LOCATE('F07', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F07) is null) or (max(goods.F07) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F08)='1' AND LOCATE('F08', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F08) is null) or (max(goods.F08) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F09)='1' AND LOCATE('F09', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F09) is null) or (max(goods.F09) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F10)='1' AND LOCATE('F10', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F10) is null) or (max(goods.F10) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F11)='1' AND LOCATE('F11', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F12)='1' AND LOCATE('F12', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F13)='1' AND LOCATE('F13', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F13) is null) or (max(goods.F13) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F14)='1' AND LOCATE('F14', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F14) is null) or (max(goods.F14) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F15)='1' AND LOCATE('F15', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F15) is null) or (max(goods.F15) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F16)='1' AND LOCATE('F16', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F16) is null) or (max(goods.F16) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F17)='1' AND LOCATE('F17', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F17) is null) or (max(goods.F17) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F18)='1' AND LOCATE('F18', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F18) is null) or (max(goods.F18) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F19)='1' AND LOCATE('F19', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F19) is null) or (max(goods.F19) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F20)='1' AND LOCATE('F20', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F20) is null) or (max(goods.F20) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F21)='1' AND LOCATE('F21', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F21) is null) or (max(goods.F21) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F22)='1' AND LOCATE('F22', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F22) is null) or (max(goods.F22) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F23)='1' AND LOCATE('F23', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F23) is null) or (max(goods.F23) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F24)='1' AND LOCATE('F24', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F24) is null) or (max(goods.F24) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F25)='1' AND LOCATE('F25', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F25) is null) or (max(goods.F25) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F26)='1' AND LOCATE('F26', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F26) is null) or (max(goods.F26) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F27)='1' AND LOCATE('F27', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F27) is null) or (max(goods.F27) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F28)='1' AND LOCATE('F28', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F28) is null) or (max(goods.F28) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F29)='1' AND LOCATE('F29', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F29) is null) or (max(goods.F29) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F30)='1' AND LOCATE('F30', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F30) is null) or (max(goods.F30) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F31)='1' AND LOCATE('F31', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F31) is null) or (max(goods.F31) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F32)='1' AND LOCATE('F32', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F32) is null) or (max(goods.F32) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F33)='1' AND LOCATE('F33', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F33) is null) or (max(goods.F33) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F34)='1' AND LOCATE('F34', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F34) is null) or (max(goods.F34) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F35)='1' AND LOCATE('F35', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F35) is null) or (max(goods.F35) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F38)='1' AND LOCATE('F38', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F38) is null) or (max(goods.F38) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F39)='1' AND LOCATE('F39', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F39) is null) or (max(goods.F39) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F40)='1' AND LOCATE('F40', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F40) is null) or (max(goods.F40) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F41)='1' AND LOCATE('F41', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F41) is null) or (max(goods.F41) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F42)='1' AND LOCATE('F42', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F42) is null) or (max(goods.F42) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F43)='1' AND LOCATE('F43', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F43) is null) or (max(goods.F43) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F44)='1' AND LOCATE('F44', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F44) is null) or (max(goods.F44) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F45)='1' AND LOCATE('F45', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F45) is null) or (max(goods.F45) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F46)='1' AND LOCATE('F46', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F46) is null) or (max(goods.F46) = ''), TRUE, FALSE)
|
|
|
+ ) AS checked
|
|
|
|
|
|
FROM OilSupplier a
|
|
|
- LEFT JOIN OilSupplierCert b ON a.Id=b.SupplierId
|
|
|
- LEFT JOIN OilSupplierCertSub sub ON b.Id=sub.SupplierCertId
|
|
|
- LEFT JOIN OilSupplierFile files ON a.Id=files.SupplierId
|
|
|
- LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
|
|
|
- LEFT JOIN OilGoodsAptitude goods ON sub.SubClassId=goods.ClassId
|
|
|
- WHERE b.SupplierTypeCode='03'
|
|
|
- GROUP BY a.Id, b.Id`
|
|
|
- sql += having
|
|
|
+ LEFT JOIN OilSupplierCert b ON a.Id=b.SupplierId
|
|
|
+ LEFT JOIN OilSupplierCertSub sub ON b.Id=sub.SupplierCertId and sub.Type in (1, 3)
|
|
|
+ LEFT JOIN OilSupplierFile files ON a.Id=files.SupplierId
|
|
|
+ LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
|
|
|
+ LEFT JOIN tmp_OilGoodsAptitudeClass class ON sub.Code=class.Code
|
|
|
+ LEFT JOIN tmp_OilGoodsAptitude goods ON class.Id=goods.ClassId
|
|
|
+ WHERE b.SupplierTypeCode='01' and `
|
|
|
+ sql += where
|
|
|
+ sql += ` GROUP BY a.Id, b.Id `
|
|
|
if asc {
|
|
|
sql += ` order by ` + orderby + ` ASC `
|
|
|
} else {
|
|
|
@@ -432,8 +434,8 @@ func (s *OilGoodsAptitudeService) GetPagingTmpCheckedEntities(entitiesPtr interf
|
|
|
if((max(goods.F08)='1' AND LOCATE('F08', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F08) is null) or (max(goods.F08) = ''), TRUE, FALSE) AND
|
|
|
if((max(goods.F09)='1' AND LOCATE('F09', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F09) is null) or (max(goods.F09) = ''), TRUE, FALSE) AND
|
|
|
if((max(goods.F10)='1' AND LOCATE('F10', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F10) is null) or (max(goods.F10) = ''), TRUE, FALSE) AND
|
|
|
- if((max(goods.F10)='1' AND LOCATE('F11', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
|
|
|
- if((max(goods.F11)='1' AND LOCATE('F12', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F11)='1' AND LOCATE('F11', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F11) is null) or (max(goods.F11) = ''), TRUE, FALSE) AND
|
|
|
+ if((max(goods.F12)='1' AND LOCATE('F12', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F12) is null) or (max(goods.F12) = ''), TRUE, FALSE) AND
|
|
|
if((max(goods.F13)='1' AND LOCATE('F13', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F13) is null) or (max(goods.F13) = ''), TRUE, FALSE) AND
|
|
|
if((max(goods.F14)='1' AND LOCATE('F14', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F14) is null) or (max(goods.F14) = ''), TRUE, FALSE) AND
|
|
|
if((max(goods.F15)='1' AND LOCATE('F15', group_concat(DISTINCT header.Code)) > 0) or (max(goods.F15) is null) or (max(goods.F15) = ''), TRUE, FALSE) AND
|
|
|
@@ -490,7 +492,7 @@ func (s *OilGoodsAptitudeService) GetPagingTmpCheckedEntities(entitiesPtr interf
|
|
|
return total
|
|
|
}
|
|
|
|
|
|
-func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage int64, orderby string,
|
|
|
+func (s *OilGoodsAptitudeService) GetPagingTmpSubEntities(pageIndex, itemsPerPage int64, orderby string,
|
|
|
asc bool, entitiesPtr interface{}, having string) (total int64) {
|
|
|
|
|
|
var sql string
|
|
|
@@ -499,7 +501,7 @@ func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage i
|
|
|
FROM OilSupplierCertSub a
|
|
|
LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId
|
|
|
LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
|
|
|
- LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId`
|
|
|
+ LEFT JOIN tmp_OilGoodsAptitude goods ON a.SubClassId=goods.ClassId`
|
|
|
sql += " where (" + having + ")"
|
|
|
sql += ` GROUP BY a.Id `
|
|
|
if asc {
|
|
|
@@ -509,7 +511,40 @@ func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage i
|
|
|
}
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
|
|
|
- sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a"
|
|
|
+ sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name LEFT JOIN tmp_OilGoodsAptitude goods ON a.SubClassId=goods.ClassId where (" + having + ")"
|
|
|
+ sqlCount += " where (" + having + ")"
|
|
|
+
|
|
|
+ var totalResult TotalResult
|
|
|
+ s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
+ s.DBE.SQL(sqlCount).Get(&totalResult)
|
|
|
+ total = totalResult.Total
|
|
|
+
|
|
|
+ return total
|
|
|
+}
|
|
|
+
|
|
|
+func (s *OilGoodsAptitudeService) GetPagingSubEntities(pageIndex, itemsPerPage int64, orderby string,
|
|
|
+ asc bool, entitiesPtr interface{}, having string) (total int64) {
|
|
|
+
|
|
|
+ var sql string
|
|
|
+ sql = `SELECT
|
|
|
+ a.*,group_concat(DISTINCT header.Code) AS HeaderCodes
|
|
|
+ FROM OilSupplierCertSub a
|
|
|
+ LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId
|
|
|
+ LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name
|
|
|
+ LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId
|
|
|
+ LEFT JOIN OilSupplierContrastNew con ON con.Id=a.SupplierId`
|
|
|
+ sql += " where (" + having + ")"
|
|
|
+ sql += ` GROUP BY a.Id `
|
|
|
+ if asc {
|
|
|
+ sql += ` order by ` + orderby + ` ASC `
|
|
|
+ } else {
|
|
|
+ sql += ` order by ` + orderby + ` DESC `
|
|
|
+ }
|
|
|
+ if itemsPerPage != 0 {
|
|
|
+ sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlCount := "SELECT count(*) as total FROM OilSupplierCertSub a LEFT JOIN OilSupplierFile files ON a.SupplierId=files.SupplierId LEFT JOIN Base_TableHeader header ON files.NeedFileType=header.Name LEFT JOIN OilGoodsAptitude goods ON a.SubClassId=goods.ClassId where (" + having + ")"
|
|
|
sqlCount += " where (" + having + ")"
|
|
|
|
|
|
var totalResult TotalResult
|